Most codebases do not announce that they use the Strategy pattern. They just stop growing if/else chains for pricing rules, shipping calculators, or auth providers. Design patterns are less a checklist to implement and more a shared vocabulary for problems you already recognize.
The Gang of Four grouped reusable object-oriented solutions into three families. Learn the names, notice where they show up in frameworks and libraries you use daily, and reach for the wiki when you need structure, code, and trade-offs.
flowchart TB subgraph creational["Creational"] Factory["Factory Method and Abstract Factory"] Builder["Builder"] end subgraph structural["Structural"] Adapter["Adapter"] Facade["Facade"] Decorator["Decorator"] Composite["Composite"] Proxy["Proxy"] end subgraph behavioral["Behavioral"] Strategy["Strategy"] State["State"] Observer["Observer"] Command["Command"] TemplateMethod["Template Method"] end
Creational patterns
Creational patterns hide the details of object construction so client code depends on abstractions, not concrete classes.
Factory Method and Abstract Factory
When new ConcreteReport() appears in a dozen places, swapping PDF for HTML becomes a scavenger hunt. Factory Method and Abstract Factory move creation behind interfaces: subclasses or factory objects decide which concrete type to build. Factory Method handles one product line; Abstract Factory coordinates whole families of related objects (UI widgets, database drivers, theme bundles) that must stay consistent.
Builder
Complex objects with many optional fields invite telescoping constructors or half-initialized instances. The Builder pattern assembles objects step by step through a fluent API, separating how you construct from what you end up with. You see it in query builders, HTTP clients, and test fixtures where readability matters as much as correctness.
Structural patterns
Structural patterns compose classes and objects into larger structures while keeping collaborations flexible.
Adapter
Integrating a third-party SDK or legacy API often means method names, return types, or units do not match what your code expects. The Adapter pattern wraps the foreign interface in one your client already understands, isolating translation in a single place instead of scattering it across call sites.
Facade
A subsystem with ten classes and a tangled call order is hard to use correctly on the first try. A Facade exposes one simplified entry point over that complexity. Application services, module public APIs, and SDK wrappers often play this role: they orchestrate internals so callers send one message instead of five.
Decorator
Subclassing for every combination of optional behavior leads to an explosion of types. The Decorator pattern wraps an object to add responsibilities at runtime while preserving the same interface. Middleware stacks, stream wrappers, and layered pricing rules are natural fits: decorators compose in any order without rewriting the core object.
Composite
Tree-shaped domains like file systems, org charts, and UI component trees tempt you to branch on βis this a leaf or a container?β everywhere. Composite gives leaves and groups a shared interface so clients treat one node and a subtree the same way. Operations like render(), getSize(), or calculateTotal() recurse uniformly through the structure.
Proxy
Sometimes you need indirection: lazy loading, access control, caching, or remote calls that look local. A Proxy implements the same interface as the real object and intercepts requests before (or instead of) forwarding them. The client sees no difference; you gain a controlled insertion point without changing the underlying type.
Behavioral patterns
Behavioral patterns govern how objects communicate and how responsibility flows between them.
Strategy
The classic smell is a method that grows a new case every sprint. Strategy extracts each variant into its own class behind a shared interface and injects the one you need at runtime. Sort orders, tax rules, compression algorithms, and payment methods all benefit from making the algorithm a plug-in rather than a branch.
State
When behavior depends on status, such as draft vs published, open vs closed, or idle vs processing, a single class stuffed with state checks becomes brittle. The State pattern delegates behavior to interchangeable state objects; transitions swap the active state instead of rewriting conditionals. State machines in workflows, connection handlers, and game logic map cleanly to this model.
Observer
One object changes and several others need to react, but wiring them with direct calls creates a web of dependencies. Observer lets dependents subscribe to a subject and receive updates when its state changes. Event buses, UI binding, and domain event notifications are all variations on the same decoupling idea.
Command
Treat a request as an object and you can queue it, log it, undo it, or defer it without the invoker knowing implementation details. The Command pattern encapsulates an action plus its parameters. Job queues, transaction logs, macro recorders, and undo stacks lean on commands to separate who triggers work from how work gets done.
Template Method
Frameworks often define a fixed sequence of steps and leave hooks for customization. Template Method puts that skeleton in a base class: the overall algorithm stays stable while subclasses override specific steps. You will recognize it in lifecycle methods, pipeline stages, and base classes that call abstract or overridable hooks in a defined order.
Patterns are not goals. A small function with no polymorphism beats a factory hierarchy nobody asked for. The payoff is recognition: when a problem shape appears, you name it, search for prior art, and choose a structure deliberately instead of copying the last workaround.
Each pattern above has a full wiki entry with diagrams, code in multiple languages, SOLID relationships, and comparisons to alternatives. Start with the one that matches a refactor on your board, then follow the related links at the bottom of each wiki page. The vocabulary compounds quickly once you have seen a few in the wild.
