Pattern Catalog¶
Creational Patterns¶
| Pattern | Purpose | Key Benefit |
|---|---|---|
| Factory | Create objects without specifying exact class | Encapsulates object creation logic |
| Singleton | Ensure only one instance exists | Controlled access to single instance |
| Builder | Construct complex objects step by step | Separates construction from representation |
| Prototype | Clone objects instead of creating new ones | Avoids expensive initialization |
| Abstract Factory | Create families of related objects | Ensures product compatibility |
Behavioral Patterns¶
| Pattern | Purpose | Key Benefit |
|---|---|---|
| Strategy | Define interchangeable algorithm families | Runtime algorithm selection |
| Observer | Notify dependents of state changes | Loose coupling between objects |
| Command | Encapsulate requests as objects | Parameterize and queue operations |
| Chain of Responsibility | Pass requests along handler chain | Decouples sender from receiver |
| Interpreter | Interpret language grammar | Represents grammar rules as classes |
| State | Alter behavior when internal state changes | State-specific behavior encapsulation |
| Template Method | Define algorithm skeleton in base class | Subclasses override specific steps |
| Iterator | Access elements sequentially | Uniform traversal interface |
| Visitor | Separate algorithms from object structure | Add operations without modifying classes |
| Mediator | Reduce coupling between communicating objects | Centralized communication |
| Memento | Capture and restore object state | Externalized state management |
Structural Patterns¶
| Pattern | Purpose | Key Benefit |
|---|---|---|
| Decorator | Add responsibilities dynamically | Flexible alternative to subclassing |
| Adapter | Make incompatible interfaces work together | Interface compatibility |
| Composite | Treat individual and composed objects uniformly | Tree structure representation |
| Facade | Provide simplified interface to complex subsystem | Reduces system complexity |
| Proxy | Control access to another object | Lazy initialization, access control |
| Bridge | Decouple abstraction from implementation | Independent variation of abstractions |