Design Patterns

Structural patterns

How to assemble classes and objects into larger structures that stay flexible.

  • 7patterns
  • 47animated steps
  • 42code examples

Structural patterns describe how to compose objects to gain new capabilities without changing existing classes: adapting an interface, adding behavior, simplifying a subsystem.

The patterns

  1. 6Adapter

    Let objects with incompatible interfaces work together, through a translator.

  2. 7Bridge

    Decouple an abstraction from its implementation so that the two can evolve independently.

  3. 8Composite

    Compose objects into tree structures and treat leaves and groups uniformly.

  4. 9Decorator

    Add behavior to an object dynamically by wrapping it in objects that share its interface.

  5. 10Facade

    Provide a simplified interface to a complex set of classes, libraries or subsystems.

  6. 11Flyweight

    Save memory by sharing the common (intrinsic) state across a large number of objects.

  7. 12Proxy

    Provide a stand-in that controls access to an object: caching, lazy loading, security, loggingโ€ฆ

At a glance

PatternAlso known asUse it for
AdapterWrapperIntegrate a third-party library / API
BridgeHandle/BodyTwo independent dimensions of variation
Compositeโ€”Tree structures: files, menus, DOM, org charts
DecoratorWrapperAdding responsibilities without modifying the class
Facadeโ€”Simplifying the use of a complex subsystem
Flyweightโ€”Very large numbers of similar objects
ProxySurrogateCaching / memoization

Other families

  • Creational patterns 5 patterns

    How to create objects flexibly, without coupling your code to concrete classes.

  • Behavioral patterns 11 patterns

    How objects communicate and share responsibilities.