The Gang of Four and Pattern Categories
In 1994, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides — collectively nicknamed the 'Gang of Four' (GoF) — published Design Patterns: Elements of Reusable Object-Oriented Software. The book catalogued 23 patterns observed repeatedly in well-designed object-oriented systems written in C++ and Smalltalk, and organized them into three categories based on the kind of problem they solve: Creational (object creation), Structural (object composition), and Behavioral (object interaction and responsibility). This taxonomy remains the standard reference point three decades later, even as newer catalogs (enterprise, concurrency, cloud) have extended it.
Cricket analogy: The way the ICC organizes formats into Test, ODI, and T20 — each with a distinct rule set solving a different problem (depth vs. speed vs. spectacle) — mirrors how the GoF organized 23 patterns into three distinct problem categories.
Creational Patterns
Creational patterns abstract the process of object instantiation, so a system does not depend on the concrete classes it creates. The five GoF creational patterns are Singleton, Factory Method, Abstract Factory, Builder, and Prototype. Factory Method lets a subclass decide which concrete class to instantiate; Abstract Factory produces families of related objects (for example, a UI toolkit that creates matching buttons, checkboxes, and scrollbars for either Windows or macOS); Builder separates the construction of a complex object from its representation, useful when an object has many optional parameters.
Cricket analogy: A franchise's scouting department deciding which type of player to sign — pace bowler, spinner, or all-rounder — based on the pitch conditions of the venue is exactly the decision-deferral that Factory Method encapsulates for object creation.
// Factory Method: defer instantiation to a subclass
interface Notification { void send(String message); }
class EmailNotification implements Notification {
public void send(String message) { System.out.println("Email: " + message); }
}
class SmsNotification implements Notification {
public void send(String message) { System.out.println("SMS: " + message); }
}
abstract class NotifierCreator {
abstract Notification createNotification();
void notifyUser(String message) {
Notification n = createNotification(); // subclass decides the concrete class
n.send(message);
}
}
class EmailNotifierCreator extends NotifierCreator {
Notification createNotification() { return new EmailNotification(); }
}
Structural and Behavioral Patterns
Structural patterns (seven in the GoF catalog: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy) deal with how classes and objects are composed to form larger structures while keeping them flexible and efficient — for instance, Adapter lets an incompatible interface work with existing client code, and Decorator attaches new responsibilities to an object dynamically without subclassing. Behavioral patterns (eleven: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor) address how objects communicate and distribute responsibility, such as Observer notifying dependents of state changes or Strategy encapsulating interchangeable algorithms behind a common interface.
Cricket analogy: A cricket commentator translating on-field hand signals from the third umpire into spoken language for TV viewers is an Adapter, converting one interface (visual signals) into another (audio commentary) the audience can consume.
A quick mnemonic: Creational patterns answer 'how is this object made?', Structural patterns answer 'how do these objects fit together?', and Behavioral patterns answer 'how do these objects talk to each other and share responsibility?'
Not every pattern you'll encounter in the wild is from the original 23. Later catalogs added patterns like Dependency Injection, Repository, and Circuit Breaker for enterprise and distributed systems — useful, but distinct from the GoF's original object-oriented taxonomy.
- The Gang of Four (Gamma, Helm, Johnson, Vlissides) published the seminal 1994 patterns catalog.
- The GoF catalog contains 23 patterns split into three categories: Creational, Structural, Behavioral.
- Creational patterns (5): Singleton, Factory Method, Abstract Factory, Builder, Prototype — they abstract object instantiation.
- Structural patterns (7): Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy — they govern how objects compose.
- Behavioral patterns (11): Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor — they govern object interaction.
- The mnemonic is: Creational = how it's made, Structural = how it fits together, Behavioral = how it communicates.
- Later catalogs (enterprise, cloud, concurrency patterns) extend but are distinct from the original GoF taxonomy.
Practice what you learned
1. Who are the 'Gang of Four'?
2. How many patterns did the original GoF catalog contain?
3. Which category does the Observer pattern belong to?
4. What problem do Creational patterns primarily address?
5. Which pattern lets an incompatible interface work with existing client code?
Was this page helpful?
You May Also Like
What Are Design Patterns?
An introduction to what design patterns actually are, how they differ from algorithms and libraries, and when applying one genuinely helps versus adds needless complexity.
Why Design Patterns Matter
Why learning design patterns pays off: they compress collective engineering experience, create shared vocabulary that speeds up communication, and encode documented trade-offs that build judgment.
Choosing the Right Pattern
A practical framework for diagnosing the actual problem in your code first, then matching it to the smallest design pattern that resolves it, and avoiding common pattern-selection mistakes.
Related Reading
Related Study Notes in Software Engineering
Browse all study notesMicroservices Study Notes
Software Architecture · 30 topics
Software EngineeringTesting & TDD Study Notes
Software Testing · 30 topics
Software EngineeringSoftware Engineering Study Notes
Python · 40 topics
Software EngineeringGit & Version Control Study Notes
Bash · 40 topics
Software EngineeringSystem Design Study Notes
Architecture · 40 topics