Wrapper Patterns (Proxy - Decorator - Adaptor - Bridge - Facade)

  • all use composition, wrapping subject
  • delegates the execution to the subject at some point
  • often maps one method call to another one
  • differ in intent and interface

Pattern

Interface to Client

Main Purpose

Wraps Existing Object?

Allows
Chaining?

Designed When

Constructor Behavior

Examples

Proxy

Same

Control access to an object

❌ (creates internally)

Runtime

No subject passed in; creates object lazily

Decorator

Same + enhanced

Add behavior without subclassing

Runtime

Takes existing object in constructor

Adapter

Different

Make incompatible interfaces compatible

After design

Takes existing object in constructor

Facade

New, simplified

Simplify complex subsystem

✅ (object graph)

After design

Takes root of complex object graph

Bridge

Abstract

Decouple abstraction & implementation

✅ (abstract impl)

Before design

Takes implementation abstraction