GoF Design Patterns Book

Introduction

This post begins with an overview of the patterns. Further links explore the individual patterns on this site, along with code examples.

The GoF design patterns originate from the book authored by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Drawing inspiration from the work of Christopher Alexander, the book captures recurring object-oriented design problems and presents design solutions that balance flexibility with clarity.

The patterns are organised into three broad categories: creational, structural, and behavioral.


Why this categorisation matters

The categories aren't rigid rules; they're thinking aids:

  • Creational patterns reduce coupling at construction time
  • Structural patterns organise relationships between objects and classes
  • Behavioral patterns clarify responsibility and collaboration

Together, they form a vocabulary for discussing design intent rather than implementation detail.

Please click on the name of a pattern for further information.


Creational Patterns

Concerned with object creation mechanisms, abstracting how objects are instantiated so systems are less dependent on concrete classes.

Name Description
Abstract Factory Create families of related objects without specifying their concrete classes
Builder Separate the construction of a complex object from its representation
Factory Method Define an interface for creating an object, letting subclasses decide which class to instantiate
Prototype Create new objects by copying an existing instance
Singleton Ensure a class has only one instance and provide a global access point

Structural Patterns

Concerned with object composition, forming larger structures while keeping them flexible and efficient.

Name Description
Adapter Convert the interface of a class into one clients expect
Bridge Decouple an abstraction from its implementation so the two can vary independently
Composite Compose objects into tree structures to represent part-whole hierarchies
Decorator Add responsibilities to objects dynamically
Facade Provide a unified, simplified interface to a subsystem
Flyweight Use sharing to support large numbers of fine-grained objects efficiently
Proxy Provide a surrogate or placeholder for another object

Behavioral Patterns

Concerned with communication and responsibility, defining how objects interact and distribute behavior.

Name Description
Chain of Responsibility Pass requests along a chain of handlers
Command Encapsulate a request as an object
Interpreter Define a representation for a language grammar and an interpreter for it
Iterator Provide a way to access elements of a collection sequentially
Mediator Centralize complex communications between objects
Memento Capture and restore an object's internal state without violating encapsulation
Observer Define a one-to-many dependency between objects
State Allow an object to alter its behavior when its internal state changes
Strategy Define a family of algorithms and make them interchangeable
Template Method Define the skeleton of an algorithm, deferring steps to subclasses
Visitor Represent an operation to be performed on elements of an object structure