Build Shapes with Swappable Renderers
Bridge pattern
Challenge 4 of Make It PluggableIntermediate~55 minFree
Learn the Bridge pattern by decoupling shapes from the backends that render them. You build a Renderer implementation hierarchy (vector and raster) and a Shape abstraction (circle and square) that talks to a renderer through a reference. Because the two hierarchies vary independently, two shapes times two renderers reuse just four classes instead of exploding into a class per combination, and you can even swap the backend at runtime.