The 23 unique design patterns, categorized into Creational, Structural, and Behavioral patterns, as outlined by the Gang of Four (GoF):
Creational Patterns (5 Patterns)
These patterns deal with object-creation mechanisms.
- Singleton – Ensures only one instance of a class is created.
- Factory Method – Creates objects without specifying the exact class.
- Abstract Factory – Provides an interface for creating related objects without specifying concrete classes.
- Builder – Separates object construction from its representation.
- Prototype – Creates a new object by cloning an existing object.
Structural Patterns (7 Patterns)
These patterns deal with object composition and structure.
- Adapter – Allows incompatible interfaces to work together.
- Bridge – Separates an object’s abstraction from its implementation.
- Composite – Treats individual objects and compositions uniformly.
- Decorator – Adds behaviour to objects dynamically.
- Facade – Provides a simplified interface to a complex system.
- Flyweight – Reduces memory usage by sharing common parts of objects.
- Proxy – Provides a placeholder or surrogate for another object.
Behavioral Patterns (11 Patterns)
These patterns are concerned with object interaction and communication.
- Chain of Responsibility – Passes requests along a chain of handlers.
- Command – Encapsulates requests as objects, allowing for parameterization.
- Interpreter – Implements a specialized language grammar.
- Iterator – Provides a way to access elements of a collection sequentially.
- Mediator – Centralizes complex communications between objects.
- Memento – Captures an object’s internal state for restoring later.
- Observer – Defines a dependency between objects to update automatically.
- State – Allows an object to change its behaviour when its state changes.
- Strategy – Enables selecting an algorithm at runtime.
- Template Method – Defines the skeleton of an algorithm, with steps overridden by subclasses.
- Visitor – Separates an algorithm from the object structure it operates on.
Top comments (0)