Design Patterns
Creational, structural and behavioral patterns with a real problem behind each one, plus honest notes on when a pattern makes things worse.
Lessons in order
- 01Intermediate 12 min
Singleton — Exactly One Instance
One shared instance for the whole application. Learn where it genuinely helps, the testing problems it creates, and what to use instead.
- 02Intermediate 12 min
Factory — Deciding What to Build
Move the decision of which class to create into one place, so the rest of your code depends only on the interface.
- 03Advanced 12 min
Abstract Factory — Families That Match
Create groups of related objects that must be used together, so a mismatched combination becomes impossible.
- 04Intermediate 12 min
Builder — Assembling Step by Step
Replace constructors with ten arguments by assembling an object step by step, validating only when it is complete.
- 05Intermediate 11 min
Adapter — Making Two Interfaces Fit
Wrap something whose interface you cannot change so it matches the interface your code expects.
- 06Intermediate 12 min
Decorator — Adding Behaviour by Wrapping
Wrap an object in another with the same interface to add logging, caching or retries, and stack the wrappers as needed.
- 07Beginner 11 min
Facade — One Simple Front Door
Give a complicated set of classes one simple entry point, so common tasks take one call instead of ten.
- 08Intermediate 12 min
Proxy — A Stand-in That Controls Access
Put a stand-in in front of an object to control access, delay expensive work, or enforce permissions.
- 09Intermediate 12 min
Strategy — Swappable Algorithms
Put each variation of an algorithm in its own class and choose between them at runtime, instead of growing a conditional.
- 10Intermediate 13 min
Observer — Telling Interested Parties
Let one object announce that something happened and let any number of listeners react, without either side knowing the other.
- 11Intermediate 12 min
Command — Actions as Objects
Turn a request into an object so it can be queued, logged, retried or undone, instead of being a method call that vanishes.
- 12Advanced 13 min
State — Behaviour That Changes With Status
When an object behaves differently depending on its status, give each status its own class and make invalid transitions impossible.
- 13Intermediate 12 min
Template Method — A Fixed Skeleton
Define the sequence of steps once in a base class and let subclasses fill in the parts that differ.