Overview

GoF Design Patterns

GoF Design Patterns are 23 reusable solutions for object-oriented software design proposed in the 1994 book 'Design Patterns: Elements of Reusable Object-Oriented Software' by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (collectively known as the 'Gang of Four'). Divided into three categories—Creational, Structural, and Behavioral patterns—they are widely used to improve software reusability, maintainability, and scalability.

design patterns GoF object-oriented software design programming
code slug name description category
C01 factory-method Factory Method Defines an interface for creating objects, but lets subclasses decide which class to instantiate. Creational Pattern
C02 abstract-factory Abstract Factory Provides an interface for creating families of related objects without specifying concrete classes. Creational Pattern
C03 singleton Singleton Ensures a class has only one instance and provides a global point of access to it. Creational Pattern
C04 prototype Prototype Creates new objects by copying existing ones. Creational Pattern
C05 builder Builder Constructs complex objects step by step, separating construction from representation. Creational Pattern
S01 adapter Adapter Allows incompatible interfaces to work together. Structural Pattern
S02 bridge Bridge Separates abstraction from implementation, allowing both to vary independently. Structural Pattern
S03 composite Composite Composes objects into tree structures to represent part-whole hierarchies. Structural Pattern
S04 decorator Decorator Adds new functionality to objects dynamically without altering their structure. Structural Pattern
S05 facade Facade Provides a simplified interface to a complex subsystem. Structural Pattern
S06 flyweight Flyweight Reduces memory usage by sharing data among similar objects. Structural Pattern
S07 proxy Proxy Provides a surrogate or placeholder for another object to control access to it. Structural Pattern
B01 chain-of-responsibility Chain of Responsibility Passes requests along a chain of handlers until one handles it. Behavioral Pattern
B02 command Command Encapsulates a request as an object, decoupling sender from receiver. Behavioral Pattern
B03 interpreter Interpreter Defines a representation for a language's grammar and interprets sentences. Behavioral Pattern
B04 iterator Iterator Provides a way to access elements of a collection sequentially. Behavioral Pattern
B05 mediator Mediator Defines how objects interact through a mediator, reducing direct dependencies. Behavioral Pattern
B06 memento Memento Captures and restores an object's internal state without violating encapsulation. Behavioral Pattern
B07 observer Observer Notifies multiple observers automatically when subject's state changes. Behavioral Pattern
B08 state State Allows an object to alter its behavior when its internal state changes. Behavioral Pattern
B09 strategy Strategy Encapsulates algorithms and makes them interchangeable at runtime. Behavioral Pattern
B10 template-method Template Method Defines the skeleton of an algorithm, deferring some steps to subclasses. Behavioral Pattern
B11 visitor Visitor Adds new operations to objects without modifying their classes. Behavioral Pattern

23 reusable solutions for object-oriented software design.