Skip to content

Gang of Four (GoF) Design Patterns

The 23 Gang of Four design patterns are reusable solutions to common object-oriented design problems, organized into three categories by purpose: Creational (how objects are made), Structural (how objects are composed), and Behavioral (how objects communicate).

History

🔗 Design Patterns — Wikipedia

Design Patterns: Elements of Reusable Object-Oriented Software was published on October 21, 1994 by Addison-Wesley (ISBN 0-201-63361-2). Its four authors — Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides — became collectively known as the "Gang of Four" (GoF).

The concept of software design patterns originated from architect Christopher Alexander's 1977 book A Pattern Language and its companion The Timeless Way of Building (1979), which cataloged recurring solutions in building and urban design. In 1987, Kent Beck and Ward Cunningham first experimented with applying Alexander's pattern ideas to programming, presenting their work at OOPSLA. The GoF authors began their collaboration at an OOPSLA workshop and refined the catalog over several years.

The book cataloged 23 patterns across three categories, with all code examples in C++ and Smalltalk, using OMT (Object Modeling Technique) notation for class diagrams — a precursor to UML. Each pattern follows a consistent template: Intent, Motivation, Applicability, Structure, Participants, Collaborations, Consequences, Implementation, Sample Code, Known Uses, and Related Patterns.

Reception & Influence

The book has sold over 500,000 copies, been translated into 13+ languages, and won the Software Development Magazine Jolt Award. It is widely regarded as one of the most influential books in software engineering. Its publication catalyzed an entire sub-field — spawning follow-up books, the Hillside Group, and the PLoP (Pattern Languages of Programs) conference series.

Before this book, developers solved the same structural problems over and over with ad-hoc solutions. The GoF gave the community a shared vocabulary: instead of explaining "I have an object that wraps another object to add behavior without subclassing," you just say "Decorator." That shared language changed how teams communicate, review code, and teach design.

Criticism

  • Language limitations disguised as patternsPeter Norvig argued in 1996 that 16 of the 23 patterns are simplified or invisible in languages with first-class functions, closures, or metaprogramming (e.g., Lisp, Python).
  • Overuse ("pattern-itis") — developers sometimes force patterns into designs where simpler solutions would suffice, leading to unnecessary complexity.
  • Static catalog — the 23 patterns are frozen from 1994; the software landscape has since evolved significantly (concurrency, functional, reactive patterns).
  • C++/Smalltalk focus — all examples are in two languages, limiting accessibility (though many third-party adaptations exist).

The book has had only one edition (1994, with minor corrections in later printings). Despite this, the patterns themselves remain foundational — they surface in modern frameworks (React's component tree is Composite, Express middleware is Chain of Responsibility, Redux is Observer + Command) whether or not the authors intended it.

The Four Authors

Author Background
Erich Gamma Swiss computer scientist. Co-created JUnit and led the Eclipse IDE's Java Development Tools and VS Code at Microsoft.
Richard Helm Australian software engineer. Worked at IBM's Thomas J. Watson Research Center.
Ralph Johnson Professor at the University of Illinois at Urbana-Champaign. Researcher in OOP and software frameworks.
John Vlissides (1961–2005) Computer scientist at IBM's Thomas J. Watson Research Center. Passed away on November 24, 2005.

How to Remember Them

Creational — S.F.A.B.P.

"Some Factories Are Building Prototypes"

Letter Pattern What it controls
S Singleton How many — exactly one instance
F Factory Method Who creates — subclasses decide
A Abstract Factory Which family — matching product sets
B Builder How it's built — step by step
P Prototype From what — clone an existing object

Structural — A.B.C.D. F.F.P.

"Adapters Bridge Composite Decorations — Facades Fly by Proxy"

Almost alphabetical — that's the trick. ABCD + FFP.

Letter Pattern What it solves
A Adapter Make incompatible interfaces work together
B Bridge Separate abstraction from implementation
C Composite Treat one and many the same (trees)
D Decorator Add behavior without subclassing
F Facade Simplify a complex subsystem
F Flyweight Share state across many objects
P Proxy Control access to an object

Behavioral — CC · II · MM · O · SS · TV

"Pairs + one loner + TV"

11 patterns are hard to memorize — but they group into 5 pairs + 1 solo:

Group Patterns Memory hook
CC Chain of Responsibility · Command Requests: route them (Chain) or wrap them (Command)
II Iterator · Interpreter Traverse: data (Iterator) or grammar (Interpreter)
MM Mediator · Memento Manage: communication (Mediator) or state snapshots (Memento)
O Observer The loner — notify many when one changes
SS State · Strategy Swap behavior: based on state (State) or by choice (Strategy)
TV Template Method · Visitor Fixed structure: override steps (Template) or add operations (Visitor)

Quick recall

  • Creational = SFABP → "Some Factories Are Building Prototypes"
  • Structural = ABCD FFP → almost alphabetical, just remember the two F's
  • Behavioral = CC · II · MM · O · SS · TV → five pairs, one loner, then TV
  • Creational Patterns


    Object creation mechanisms — abstracting instantiation to make systems independent of how objects are created, composed, and represented.

    Singleton · Factory Method · Abstract Factory · Builder · Prototype

    Read more

  • Structural Patterns


    Object composition and relationships — assembling objects and classes into larger structures while keeping them flexible and efficient.

    Adapter · Bridge · Composite · Decorator · Facade · Flyweight · Proxy

    Read more

  • Behavioral Patterns


    Object communication and responsibility distribution — making complex control flows easier to understand and maintain.

    Chain of Responsibility · Command · Iterator · Mediator · Memento · Observer · State · Strategy · Template Method · Visitor · Interpreter

    Read more