Skip to main content

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.

PatternCategoryIntentComplexityPopularityConfused with
Factory MethodcreationalLet a superclass define how a product is used while subclasses decide which concrete product gets created.Abstract Factory, Builder
Abstract FactorycreationalProduce 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
BuildercreationalAssemble a complex object step by step, so the same construction sequence can produce different representations without a monstrous constructor.Factory Method, Abstract Factory
PrototypecreationalLet objects copy themselves through a shared clone method, so client code duplicates them without knowing their concrete classes.copy-constructors, Factory Method
SingletoncreationalGuarantee a class has exactly one instance and give the whole program a single access point to it.static-class, Flyweight
AdapterstructuralLet two objects with incompatible interfaces collaborate by putting a translator between them.Decorator, Proxy, Facade, Bridge
BridgestructuralSplit 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
CompositestructuralArrange 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
DecoratorstructuralAttach 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
FacadestructuralPut one simple, purpose-built interface in front of a complicated subsystem so client code stops depending on its internals.Mediator, Adapter, Proxy
FlyweightstructuralFit more objects in RAM by splitting out the state they all duplicate and sharing one immutable copy of it between them.Singleton, Facade, Composite
ProxystructuralStand 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 ResponsibilitybehavioralPass 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
CommandbehavioralWrap 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
IteratorbehavioralMove 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
MediatorbehavioralBan 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
MementobehavioralCapture and restore an object's previous state without exposing a single one of its private fields to the outside world.Prototype, Command
ObserverbehavioralLet objects subscribe to events on a publisher and get notified automatically, without the publisher knowing who they are.Mediator, Chain of Responsibility
StatebehavioralLet an object change its behavior when its internal state changes, so completely that it appears to have changed its class.Strategy, Template Method, Bridge
StrategybehavioralDefine 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 MethodbehavioralFix the skeleton of an algorithm in a superclass and let subclasses override individual steps without touching its structure.Strategy, State, Factory Method
VisitorbehavioralSeparate an algorithm from the object structure it runs over, so new operations can be added without editing the element classes.Command, Composite, Iterator
Null ObjectadditionalReplace `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
RepositoryadditionalPut 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-ControlleradditionalSeparate 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 InjectionadditionalHand 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
SpecificationadditionalEncapsulate 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 LoopadditionalRun 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 PooladditionalKeep 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 ConsumeradditionalLet 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
0%0 of 122 pages studied