DEV Community

Jayaprasanna Roddam
Jayaprasanna Roddam

Posted on

Design patterns

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.

  1. Singleton – Ensures only one instance of a class is created.
  2. Factory Method – Creates objects without specifying the exact class.
  3. Abstract Factory – Provides an interface for creating related objects without specifying concrete classes.
  4. Builder – Separates object construction from its representation.
  5. Prototype – Creates a new object by cloning an existing object.

Structural Patterns (7 Patterns)

These patterns deal with object composition and structure.

  1. Adapter – Allows incompatible interfaces to work together.
  2. Bridge – Separates an object’s abstraction from its implementation.
  3. Composite – Treats individual objects and compositions uniformly.
  4. Decorator – Adds behaviour to objects dynamically.
  5. Facade – Provides a simplified interface to a complex system.
  6. Flyweight – Reduces memory usage by sharing common parts of objects.
  7. Proxy – Provides a placeholder or surrogate for another object.

Behavioral Patterns (11 Patterns)

These patterns are concerned with object interaction and communication.

  1. Chain of Responsibility – Passes requests along a chain of handlers.
  2. Command – Encapsulates requests as objects, allowing for parameterization.
  3. Interpreter – Implements a specialized language grammar.
  4. Iterator – Provides a way to access elements of a collection sequentially.
  5. Mediator – Centralizes complex communications between objects.
  6. Memento – Captures an object’s internal state for restoring later.
  7. Observer – Defines a dependency between objects to update automatically.
  8. State – Allows an object to change its behaviour when its state changes.
  9. Strategy – Enables selecting an algorithm at runtime.
  10. Template Method – Defines the skeleton of an algorithm, with steps overridden by subclasses.
  11. Visitor – Separates an algorithm from the object structure it operates on.

Top comments (0)