advanced

Bridge

Separate an abstraction from its implementation so two dimensions of variation can evolve without subclass explosion.

Bridge splits an abstraction from its implementation so two dimensions of variation evolve independently—shape versus renderer, message channel versus transport, domain API versus storage backend. It prevents combinatorial subclass explosion such as `RedCircle`, `BlueCircle`, `RedSquare`.

On interviews: diagram abstraction holding implementation reference. Compare with Adapter (after the fact) and Strategy (algorithm swap).

Common pitfalls: leaking implementation types through abstraction; bridge with only one implementation left in production; over-abstracting stable code.

The trade-off is flexibility versus complexity—know when the simpler path is enough.

Checklist:

  • Two orthogonal axes identified clearly.
  • Abstraction delegates to implementation interface.
  • New implementations do not require new abstractions.
  • Integration tests per implementation pair.