Structural Patterns
How classes and objects fit together into bigger structures.
7 lessons · follow them in order, or jump to what you need.
Adapter Pattern: The Travel Plug Trick That Makes Old Code Fit New Code
Learn the Adapter pattern with a simple 3-pin plug and 2-pin socket story. Make old code work with new code without changing either side. Easy examples.
Bridge Pattern: One Remote, Many Devices — Stop the Subclass Explosion
Understand the Bridge pattern with a TV and remote story. Split one big class into two parts that grow separately, so you avoid too many extra subclasses.
Composite Pattern: Boxes Inside Boxes — Treat One Thing and Many Things Alike
Learn the Composite pattern with boxes inside a courier parcel. Treat one item and a full group the same way, and add totals easily with simple recursion.
Decorator Pattern: Add Toppings to Your Objects, One Layer at a Time
Learn the Decorator pattern with a simple dosa-toppings story. Wrap objects in layers to add new behaviour at runtime, without making new subclasses.
Facade Pattern: One Travel Agent for Your Whole Messy Trip
Learn the Facade pattern with a travel agent story. Hide many complicated subsystems behind one simple method so client code stays short and clean.
Flyweight Pattern: One Jersey Design, a Whole Team of Players
Learn the Flyweight pattern with a cricket jersey story. Share the heavy common data between thousands of objects and save huge amounts of memory.
Proxy Pattern: The Watchman Who Checks Before You Meet the Owner
Learn the Proxy pattern with a society watchman story. Put a stand-in with the same interface in front of a real object to control access to it.