Skip to main content

Design Patterns Overview

This section collects GoF patterns with practical examples and guidance. Use it to pick a suitable pattern, not to force one.

Quick decision guide

  • Object creation is complex → look at Creational patterns.
  • You need to compose behavior → look at Structural patterns.
  • You want flexible interactions → look at Behavioral patterns.

Common comparisons (quick picks)

  • Strategy vs State: Strategy is chosen by the client; State changes from within the object.
  • Adapter vs Facade: Adapter changes an interface; Facade simplifies a subsystem.
  • Decorator vs Proxy: Decorator adds behavior; Proxy controls access.

Pattern map (by intent)

IntentPatterns
Create one objectSingleton
Create familiesAbstract Factory
Create step-by-stepBuilder
Reuse similar objectsPrototype
Decouple creationFactory Method
Adapt interfacesAdapter
Simplify subsystemsFacade
Compose treesComposite
Add behaviorDecorator
Control accessProxy
Share stateFlyweight
Vary implementationBridge
Chain handlersChain of Responsibility
Encapsulate actionsCommand
Define languagesInterpreter
Traverse collectionsIterator
Centralize communicationMediator
Snapshot stateMemento
Notify observersObserver
Switch behavior by stateState
Swap algorithmsStrategy
Fixed algorithm stepsTemplate Method
Add operationsVisitor

Next steps

  • Start with the closest intent.
  • Check “Related patterns” for alternatives.
  • If two patterns fit, pick the simpler one.