All challenges
intermediateDesign Patterns~55 min

Shapes and Renderers (Bridge Pattern)

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.