Design PatternsStructural Patterns
Structural Patterns
Patterns that deal with object composition and relationships
Structural Patterns
Structural design patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.
The Patterns
Adapter
Convert the interface of a class into another interface clients expect
Bridge
Decouple an abstraction from its implementation so both can vary independently
Composite
Compose objects into tree structures to represent part-whole hierarchies
Decorator
Attach additional responsibilities to an object dynamically
Facade
Provide a unified interface to a set of interfaces in a subsystem
Flyweight
Use sharing to support large numbers of fine-grained objects efficiently
Proxy
Provide a surrogate or placeholder for another object to control access
Quick Comparison
| Pattern | Intent | Complexity | Frequency |
|---|---|---|---|
| Adapter | Make incompatible interfaces work together | ⭐⭐ | Very Common |
| Bridge | Separate abstraction from implementation | ⭐⭐⭐ | Common |
| Composite | Compose objects into trees | ⭐⭐ | Common |
| Decorator | Add responsibilities dynamically | ⭐⭐ | Common |
| Facade | Simplify complex subsystems | ⭐ | Very Common |
| Flyweight | Share common state efficiently | ⭐⭐⭐ | Less Common |
| Proxy | Control access to objects | ⭐⭐ | Common |