Structural patterns organize relationships between objects. They solve different boundary problems: incompatible interfaces, recursive part-whole trees, independently changing dimensions, layered behavior, simplified subsystem access, shared intrinsic state, and controlled access. The right pattern follows from the relationship that must remain stable.
Patterns at a Glance
These patterns can share nearly identical class diagrams while serving different intents. Decorator and Proxy both wrap an interface. Adapter and Facade both sit at a boundary. Selection depends on whether the design needs translation, simplification, behavior, access control, hierarchy, independent variation, or memory sharing. Several may coexist in one system.
| Pattern | Intent | Reach for it when |
|---|---|---|
| Software Architecture/Patterns/Design Patterns/Structural/Adapter | Translate an existing interface into the contract a client expects. | A legacy or third-party API cannot be changed, but the client requires another shape. |
| Software Architecture/Patterns/Design Patterns/Structural/Bridge | Separate an abstraction from its implementation so both dimensions can vary. | Two independent dimensions would otherwise produce an N×M set of classes. |
| Software Architecture/Patterns/Design Patterns/Structural/Composite | Represent part-whole trees through one component interface. | Clients should apply the same operation to a leaf or a group. |
| Software Architecture/Patterns/Design Patterns/Structural/Decorator | Add behavior through same-interface wrappers. | Optional behaviors need explicit composition without subclassing. |
| Software Architecture/Patterns/Design Patterns/Structural/Facade | Present a high-level entry point over a complex subsystem. | Several clients repeat the same subsystem workflow. |
| Software Architecture/Patterns/Design Patterns/Structural/Flyweight | Share immutable intrinsic state across many fine-grained objects. | Retained duplicate state is a measured memory cost. |
| Software Architecture/Patterns/Design Patterns/Structural/Proxy | Control access through a same-interface surrogate. | Access must be deferred, cached, authorized, or made remote without changing clients. |
Questions
Decorator and Proxy can have the same class structure. What determines which pattern is present?
Intent. A Decorator adds composable behavior to an object. A Proxy controls access to another object, perhaps by deferring creation or enforcing authorization. The wrapper’s responsibility and the reason it exists matter more than the diagram.