Cheat-Sheet
All 22 patterns in one sortable place. Each row is pulled live from its pattern page, so this table can never drift out of date.
| Pattern | Category | Intent | Complexity | Popularity | Confused with |
|---|---|---|---|---|---|
| Factory Method | creational | Let a superclass define how a product is used while subclasses decide which concrete product gets created. | Abstract Factory, Builder | ||
| Abstract Factory | creational | Produce whole families of related objects through one interface, so the client never picks a concrete class and never gets a mismatched set. | Factory Method, Builder | ||
| Builder | creational | Assemble a complex object step by step, so the same construction sequence can produce different representations without a monstrous constructor. | Factory Method, Abstract Factory | ||
| Prototype | creational | Let objects copy themselves through a shared clone method, so client code duplicates them without knowing their concrete classes. | copy-constructors, Factory Method | ||
| Singleton | creational | Guarantee a class has exactly one instance and give the whole program a single access point to it. | static-class, Flyweight | ||
| Adapter | structural | Let two objects with incompatible interfaces collaborate by putting a translator between them. | Decorator, Proxy, Facade, Bridge | ||
| Bridge | structural | Split a class that varies along two independent axes into two hierarchies - control and platform - joined by a reference, so each can grow without touching the other. | Strategy, Adapter, State | ||
| Composite | structural | Arrange objects into a tree and give leaves and containers the same interface, so the client can treat one item and a whole branch identically. | Decorator, Chain of Responsibility, Iterator | ||
| Decorator | structural | Attach extra behavior to an object by wrapping it in another object that implements the same interface, stackable as many layers deep as you like. | Adapter, Proxy, Composite, Strategy, Chain of Responsibility | ||
| Facade | structural | Put one simple, purpose-built interface in front of a complicated subsystem so client code stops depending on its internals. | Mediator, Adapter, Proxy | ||
| Flyweight | structural | Fit more objects in RAM by splitting out the state they all duplicate and sharing one immutable copy of it between them. | Singleton, Facade, Composite | ||
| Proxy | structural | Stand in for another object behind an identical interface so you can control access to it - lazy loading, caching, permissions, logging - without touching it or its clients. | Decorator, Adapter, Facade | ||
| Chain of Responsibility | behavioral | Pass a request along a line of handler objects; each one decides whether to handle it, pass it on, or stop the chain dead. | Decorator, Command, Observer, Mediator | ||
| Command | behavioral | Wrap a request - receiver, method, arguments and all - in its own object, so it can be passed around, queued, logged, and undone. | Strategy, Chain of Responsibility, Observer, Mediator | ||
| Iterator | behavioral | Move the job of walking a collection out of the collection and into a separate object, so clients traverse anything without learning how it is stored. | Composite, Factory Method, Visitor | ||
| Mediator | behavioral | Ban components from talking to each other directly and route every interaction through one mediator object, so nobody depends on anybody except the hub. | Observer, Facade, Command, Chain of Responsibility | ||
| Memento | behavioral | Capture and restore an object's previous state without exposing a single one of its private fields to the outside world. | Prototype, Command | ||
| Observer | behavioral | Let objects subscribe to events on a publisher and get notified automatically, without the publisher knowing who they are. | Mediator, Chain of Responsibility | ||
| State | behavioral | Let an object change its behavior when its internal state changes, so completely that it appears to have changed its class. | Strategy, Template Method, Bridge | ||
| Strategy | behavioral | Define a family of interchangeable algorithms, put each in its own class, and let the client decide which one the context uses. | State, Template Method, Command, Decorator | ||
| Template Method | behavioral | Fix the skeleton of an algorithm in a superclass and let subclasses override individual steps without touching its structure. | Strategy, State, Factory Method | ||
| Visitor | behavioral | Separate an algorithm from the object structure it runs over, so new operations can be added without editing the element classes. | Command, Composite, Iterator | ||
| Null Object | additional | Replace `null` with a real object that implements the same interface but does nothing (or does something safely neutral), so callers never need a null-check. | State, Strategy | ||
| Repository | additional | Put a collection-like interface between domain logic and data access, so business code depends on `find`/`save` instead of SQL, an ORM, or an API client. | Facade, Adapter | ||
| Model-View-Controller | additional | Separate what an application knows (Model) from how it is shown (View) from how input is handled (Controller), so a change to the display never has to touch business logic. | Observer, Mediator | ||
| Dependency Injection | additional | Hand a class its collaborators from the outside (constructor, setter, or a framework) instead of letting it construct them itself, so it depends on an interface without knowing how to build what implements it. | Factory Method, Strategy | ||
| Specification | additional | Encapsulate a business rule as an object with an isSatisfiedBy(candidate) method, instead of scattering boolean logic through the codebase, so rules can be named, tested alone, and combined with AND/OR/NOT. | Strategy, Chain of Responsibility | ||
| Game Loop | additional | Run a loop that continuously reads input, advances state, and renders output at a controlled cadence for the entire active lifetime of a program - the opposite of waiting idle for the next request. | Template Method, Observer | ||
| Thread Pool | additional | Keep a fixed set of worker threads that pull tasks from a shared queue, so thread-creation cost is paid once and concurrency stays bounded, instead of spawning one new thread per task. | Producer Consumer, Flyweight | ||
| Producer Consumer | additional | Let producers put items on a shared queue and consumers take them off at their own pace, so a bounded buffer absorbs bursts and decouples how fast work arrives from how fast it gets handled. | Thread Pool, Observer |