- Guides
- Design patterns
Design patterns
The 22 classic object-oriented patterns. Each one with its own scenario, not the usual textbook examples.
22 guides3 groups271 min in total
Creational patterns
Patterns for creating objects without tying your code to concrete classes.
About this group0 of 5 read- 1Factory Method: Let Subclasses Decide Which Object to Create11 min
- 2Abstract Factory: Create Families of Objects That Belong Together12 min
- 3Builder Pattern: Assemble Complex Objects Step by Step14 min
- 4Prototype Pattern: Create Objects by Cloning a Configured Instance12 min
- 5Singleton: One Shared Instance, and Why You Usually Want DI Instead12 min
Structural patterns
Patterns for putting objects together into larger structures that stay flexible.
About this group0 of 7 read- 1Adapter Pattern: Fit a Third-Party SDK Into Your Own Interface11 min
- 2Bridge Pattern: Split Abstraction from Implementation12 min
- 3Composite Pattern: Treat Single Items and Groups Through One Interface12 min
- 4Decorator: Add Behaviour by Wrapping, the Way Middleware Does13 min
- 5Facade Pattern: One Simple Entry Point to a Messy Subsystem11 min
- 6Flyweight Pattern: Share Immutable State Across Many Objects12 min
- 7Proxy Pattern: Control Access with a Stand-In Object13 min
Behavioral patterns
Patterns about how objects share responsibilities and talk to each other.
About this group0 of 10 read- 1Chain of Responsibility: Pass a Request Along Until One Handles It14 min
- 2Command Pattern: Turn Requests into Objects You Can Queue and Undo13 min
- 3Iterator Pattern: Walk Any Collection Without Knowing Its Shape14 min
- 4Mediator: Route Component Chatter Through One Coordinator12 min
- 5Memento Pattern: Save and Restore State Without Exposing It13 min
- 6Observer Pattern: Notify Subscribers Without Coupling to Them13 min
- 7State Pattern: Explicit State Machines Without the Switch Statements13 min
- 8Strategy: swap the rule without touching who uses it9 min
- 9Template Method: A Fixed Algorithm With Steps Subclasses Fill In13 min
- 10Visitor Pattern: Add Operations Without Editing Your Classes12 min
About this section
- What these guides are
- A design pattern is a known solution to a recurring problem when organising classes and objects. In an interview you may be asked to spot one in some code, apply one in an exercise or explain when not to use it. Knowing their names gives you a quick vocabulary for talking about design.
- How they are organised
- The patterns are grouped into the three classic categories: creational, structural and behavioral. Each category answers a different question: how objects are created, how they are combined and how they share the work.
- How each guide works
- Each guide explains the problem the pattern solves, the solution and an analogy, with a structure diagram and its participants. Then come when to apply it, how to implement it step by step, pros and cons, how it relates to other patterns and code in TypeScript, Python and PHP.
- Where to start
- Start with Strategy, Observer and Adapter, the ones that come up most in interviews and in real code. Then work through the categories at your own pace.