Skip to content

What Are Design Patterns?

Design patterns are reusable, battle-tested solutions to common problems in software design.

Think of them like blueprints — not finished code you copy-paste, but a template you adapt to your situation.

A chef doesn’t invent a new recipe every time someone orders an omelette. They follow a proven pattern — crack eggs, whisk, cook — and tweak it for the customer’s taste.

Design patterns work the same way: proven solutions you customize for your app.


In 1994, four authors (Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides) published Design Patterns: Elements of Reusable Object-Oriented Software. They cataloged 23 patterns divided into 3 categories.


flowchart TB
GoF[Gang of Four<br/>23 Patterns] --> Creational[🏗️ Creational<br/>How objects are created]
GoF --> Structural[🔧 Structural<br/>How objects are composed]
GoF --> Behavioral[🔄 Behavioral<br/>How objects communicate]
Creational --> S1[Singleton]
Creational --> F1[Factory Method]
Creational --> AF[Abstract Factory]
Creational --> B1[Builder]
Creational --> P1[Prototype]
Structural --> Ad[Adapter]
Structural --> Dec[Decorator]
Structural --> Fac[Facade]
Structural --> Pr[Proxy]
Structural --> Com[Composite]
Structural --> Br[Bridge]
Structural --> Fly[Flyweight]
Behavioral --> Ob[Observer]
Behavioral --> St[Strategy]
Behavioral --> Cmd[Command]
Behavioral --> It[Iterator]
Behavioral --> Sta[State]
Behavioral --> TM[Template Method]
Behavioral --> CoR[Chain of Resp.]
Behavioral --> Med[Mediator]
Behavioral --> Mem[Memento]
Behavioral --> Vis[Visitor]
style GoF fill:#7c3aed,color:#fff
style Creational fill:#06b6d4,color:#fff
style Structural fill:#f59e0b,color:#fff
style Behavioral fill:#ef4444,color:#fff

How objects are created.

Instead of new everywhere, creational patterns give you flexible object creation.

PatternWhat It Does
SingletonOne shared instance for the whole app
Factory MethodLet subclasses decide which class to instantiate
Abstract FactoryFamilies of related objects without specifying concrete classes
BuilderConstruct complex objects step by step
PrototypeClone existing objects instead of creating new ones

How objects are composed.

Structural patterns assemble objects into larger structures while keeping them flexible.

PatternWhat It Does
AdapterMake incompatible interfaces work together
DecoratorAdd behavior to an object without changing its class
FacadeProvide a simple interface to a complex subsystem
ProxyControl access to another object
CompositeTreat individual and group objects the same way
BridgeSeparate abstraction from implementation
FlyweightShare data across many objects to save memory

How objects communicate.

Behavioral patterns manage algorithms, responsibilities, and communication between objects.

PatternWhat It Does
ObserverNotify multiple objects when something changes
StrategySwap algorithms at runtime
CommandWrap a request as an object
IteratorTraverse a collection without exposing internals
StateChange behavior when internal state changes
Template MethodDefine skeleton, let subclasses fill details
Chain of ResponsibilityPass a request along a chain of handlers
MediatorCentralize complex communication
MementoSave and restore object state
VisitorAdd new operations without changing classes

ReasonExplanation
🧠 ProvenTested by thousands of developers over decades
🗣️ Shared vocabulary”Let’s use an Observer here” — everyone understands
🔧 MaintainableLoosely coupled, easy to change code
🚫 Avoid reinventionDon’t solve problems that have already been solved
  • Over-engineering: Don’t add a Factory for a single class
  • Simple problems: A simple function is better than a pattern
  • Performance-critical: Some patterns add overhead (Proxy, Decorator)

  • Design patterns are proven blueprints for common coding problems
  • There are 23 classic patterns from the Gang of Four
  • They’re grouped into 3 categories: Creational, Structural, Behavioral
  • They give you a shared vocabulary with other developers
  • Use them when the problem fits — but don’t force them