Object-oriented Patterns Reference

Reusable object-oriented software design patterns.

Object-oriented Patterns Reference

Intent, fit, trade-offs, and relationships for major object-oriented design patterns.

Updated 2026-07-22

Abstract Factory

Provide an interface for creating related or dependent objects without exposing their concrete classes.

AspectGuidance
Use whenA product family must stay compatible while its concrete implementation can vary.
Trade-offsAdds factories and product interfaces; extending the family with a new product kind affects every factory.
RelatedFactory Method, Prototype

Builder

Separate the construction of a complex object from its final representation.

AspectGuidance
Use whenConstruction has ordered steps, many optional values, or multiple outputs.
Trade-offsIntroduces another abstraction and can be excessive for simple immutable values.
RelatedAbstract Factory, Factory Method

Factory Method

Define a creation operation while allowing implementations to select the concrete product.

AspectGuidance
Use whenA base workflow depends on an object whose exact type varies.
Trade-offsOften requires subclassing or injected creators and increases the number of types.
RelatedAbstract Factory, Template Method

Prototype

Create new objects by copying an existing configured object.

AspectGuidance
Use whenInitialization is expensive or runtime configuration matters more than concrete classes.
Trade-offsCorrectly copying identity, cycles, and mutable nested state can be difficult.
RelatedFactory Method, Memento

Singleton

Provide one shared instance within an explicitly defined scope.

AspectGuidance
Use whenExactly one coordinator or resource owner is required for that scope.
Trade-offsCreates global coupling, complicates tests, and can hide lifecycle and concurrency concerns.
RelatedDependency Injection, Abstract Factory

Adapter

Convert an existing interface into the interface a client expects.

AspectGuidance
Use whenReusing a class, library, or service with an incompatible contract.
Trade-offsTranslation can conceal semantic mismatches and adds another layer.
RelatedBridge, Facade, Proxy

Bridge

Separate an abstraction from its implementation so both dimensions can evolve independently.

AspectGuidance
Use whenTwo varying dimensions would otherwise create a subclass explosion.
Trade-offsMore indirection and up-front design are required.
RelatedAdapter, Strategy

Composite

Represent part-whole trees while treating leaves and containers through one interface.

AspectGuidance
Use whenClients should apply operations uniformly across a hierarchy.
Trade-offsA broad common interface may allow operations that make little sense for some nodes.
RelatedDecorator, Iterator, Visitor

Decorator

Attach responsibilities to an object dynamically by wrapping it.

AspectGuidance
Use whenBehavior must be combined independently without a large inheritance hierarchy.
Trade-offsMany small wrappers complicate identity, debugging, and ordering.
RelatedComposite, Proxy, Chain of Responsibility

Facade

Provide a focused interface over a larger or more complex subsystem.

AspectGuidance
Use whenMost clients need a stable, convenient entry point rather than full subsystem access.
Trade-offsA facade can grow into an oversized coordinator or conceal useful capabilities.
RelatedAdapter, Mediator

Flyweight

Share intrinsic state among many fine-grained objects.

AspectGuidance
Use whenA very large number of similar objects makes duplicated state expensive.
Trade-offsClients must manage external state and shared objects must remain safe to reuse.
RelatedComposite, Factory Method

Proxy

Use a stand-in that controls access to another object.

AspectGuidance
Use whenAccess needs laziness, authorization, remote communication, caching, or instrumentation.
Trade-offsAdds latency and indirection; behavior can surprise clients if the proxy is not transparent.
RelatedAdapter, Decorator

Chain of Responsibility

Send a request through a sequence of potential handlers.

AspectGuidance
Use whenThe handler is not known in advance or several handlers may contribute.
Trade-offsRequests may go unhandled and the effective control flow becomes less visible.
RelatedCommand, Decorator

Command

Encapsulate a request as an object with its parameters and execution behavior.

AspectGuidance
Use whenOperations need queues, retries, logs, scheduling, or undo.
Trade-offsCreates extra objects and undo requires careful state capture.
RelatedMemento, Chain of Responsibility

Interpreter

Represent a grammar and evaluate sentences in that grammar.

AspectGuidance
Use whenA small, stable language must be evaluated repeatedly.
Trade-offsLarge grammars become slow and hard to maintain; a parser generator may fit better.
RelatedComposite, Visitor

Iterator

Traverse a collection without exposing its internal representation.

AspectGuidance
Use whenClients need a uniform traversal API or multiple traversal strategies.
Trade-offsMutation during traversal and resource-backed iterators require explicit semantics.
RelatedComposite, Visitor

Mediator

Coordinate interactions through a dedicated object instead of many direct dependencies.

AspectGuidance
Use whenA group of objects has dense, difficult-to-change communication.
Trade-offsThe mediator can accumulate too many responsibilities.
RelatedObserver, Facade

Memento

Capture an object’s state without exposing its implementation so it can later be restored.

AspectGuidance
Use whenUndo, checkpoints, or rollback must preserve encapsulation.
Trade-offsSnapshots may consume substantial memory and can become invalid as schemas evolve.
RelatedCommand, Prototype

Observer

Notify registered dependents when a subject changes.

AspectGuidance
Use whenMultiple consumers react to state changes without tight coupling.
Trade-offsNotification order, failures, reentrancy, and subscriber lifetimes require clear rules.
RelatedMediator, Event-driven Consumer

State

Delegate behavior to an object representing the current state.

AspectGuidance
Use whenConditionals vary behavior across a well-defined state machine.
Trade-offsAdds types and transition ownership must be designed carefully.
RelatedStrategy, Template Method

Strategy

Encapsulate interchangeable algorithms behind one contract.

AspectGuidance
Use whenA behavior varies independently from the client that uses it.
Trade-offsClients or configuration must choose correctly, and tiny strategies may add noise.
RelatedState, Bridge, Template Method

Template Method

Define an algorithm skeleton while allowing selected steps to vary.

AspectGuidance
Use whenRelated workflows share ordering and invariant steps.
Trade-offsInheritance couples variants to the base class and hook methods can obscure flow.
RelatedFactory Method, Strategy

Visitor

Define operations over a stable object structure without changing its element types.

AspectGuidance
Use whenMany unrelated operations target a hierarchy whose element types rarely change.
Trade-offsAdding element types affects every visitor and traversal can expose internals.
RelatedComposite, Iterator

Dependency Injection

Supply an object’s collaborators from outside rather than constructing them internally.

AspectGuidance
Use whenImplementations, lifetimes, or test doubles must vary independently.
Trade-offsObject assembly moves elsewhere and runtime containers may hide the dependency graph.
RelatedAbstract Factory, Strategy

Null Object

Represent the absence of behavior with an object that honors the expected contract.

AspectGuidance
Use whenOptional collaborators otherwise require repeated null checks.
Trade-offsCan hide missing configuration or failures when absence should be explicit.
RelatedStrategy, Special Case

Specification

Represent a business predicate as a named, composable object.

AspectGuidance
Use whenRules must be reused, combined, explained, or translated into queries.
Trade-offsToo many small specifications can obscure simple rules and translation support is limited.
RelatedComposite, Strategy

Description

Reusable object-oriented software design patterns.

References

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies