When to use
When you need to extend functionality, simplify interfaces, or manage relationships between objects without tight coupling.
Key traits
- Focus on class/object composition
- Enable new functionality through object relationships
- Simplify complex structures through wrappers or intermediaries
- Maintain flexibility and extensibility
Common Scenarios
| Pattern | When to Use |
|---|---|
| ๐ Decorator | Adding responsibilities to objects dynamically without modifying their code |
| ๐ Adapter | Making incompatible interfaces work together (legacy integration) |
| ๐๏ธ Facade | Providing a simple interface to a complex subsystem or library |
| ๐ช Proxy | Controlling access, lazy loading, or adding cross-cutting concerns |
| ๐ณ Composite | Treating individual objects and compositions uniformly (tree structures) |
| ๐ Bridge | Separating abstraction from implementation to vary them independently |
| ๐ชถ Flyweight | Sharing common state to efficiently support large numbers of fine-grained objects |