When to select Design Pattern
Choosing the correct design pattern in software engineering is critical to practical problem-solving. This post will try to simplify the process, helping you decide between patterns based on specific needs.
To select a pattern, we must first go through the problem identification. If the problem is related to:
Object Creation? - Creational Patterns
Object Assembly? - Structural Patterns
Object Interections? - Behavioral Patterns
Singleton: Ensures only one instance exists.
Factory Method: Delegates object instantiation to subclasses.
Abstract Factory: Creates related object families without specifying their concrete classes.
Prototype: Clones objects for a prototypical instance.
Builder: Constructs complex objects step by step.
Adapter: Bridges incompatible interfaces.
Bridge: Separates abstraction from implementation.
Composite: Treats single and composite objects uniformly.
Decorator: Adds behaviors to objects dynamically.
Facade: Simplifies complex system interfaces.
Flyweight: Shares objects to reduce memory.
Proxy: Controls object access.
Observer: Notifies changes to multiple objects.
Strategy: Encapsulates interchangeable algorithms.
Command: Encapsulates a request as an object.
State: Changes object behavior with internal state.
Visitor: Adds operations to object structures without modifying them.
Memento: Captures and restores object states externally.
Iterator: Sequentially accesses elements of a collection.
Mediator: Centralizes complex communications.
Chain of Responsibility: Passes requests along a chain of handlers.
Template Method: Defines the skeleton of an algorithm.