Docs

Design Patterns — Fast Recall (Python)

The 3 categories (map first, then recall)


  • A design pattern is a named, reusable solution to a recurring design problem — a shared vocabulary, not copy-paste code.
  • Creational — *how objects get made*: Singleton, Factory, Builder.
  • Structural — *how objects are composed*: Adapter, Facade, Decorator, Proxy.
  • Behavioral — *how objects talk & share responsibility*: Strategy, Observer, Command, State, Template Method.
  • One-line intents: Singleton = one instance · Factory = pick class at runtime · Builder = step-by-step build · Adapter = translate interface · Facade = simple front for complex · Decorator = wrap to add behavior · Proxy = stand-in that controls access · Strategy = swap algorithm · Observer = notify subscribers · Command = request as object · State = behavior follows state · Template = fixed skeleton, variable steps.
  • Golden rule: reach for a pattern to remove a real pain (rigidity, duplication, tight coupling) — never to look clever. In Python, a function or a `dict` often beats a class-heavy pattern.