Skip to content

12 — Structural Patterns

Driving question: How can structure adapt without turning every dependency into a wrapper?

Learning objectives

  • Compare Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and Proxy.
  • Distinguish structural similarity from intent.
  • Identify when indirection localizes change.
  • Recognize wrapper/decorator chains that harm diagnosability.

Similar shape, different intent

Proxy and Decorator may both wrap an object with the same interface. Their intent differs:

  • Decorator: add responsibilities dynamically.
  • Proxy: control access to another object.

Adapter may also wrap an object, but changes the interface expected by the client.

This is crucial for automated pattern detection: class-diagram structure alone may be insufficient to infer intent.

Composition as a design tool

Composite is powerful when clients should treat individual objects and groups uniformly. Bridge separates two dimensions of variation that would otherwise create an inheritance-product explosion.

Design / research exercise

Given a wrapper-heavy codebase, classify five wrappers as Adapter, Decorator, Proxy, Facade, or “none of these.” Use behavior and change intent, not class names.

Suggested reading

  • GoF, Structural Patterns chapters.