Bridge (aka Handle | Body)
Intent
Decouple an abstraction from its implementation so that the two can vary independently.
Problem
An abstraction and its implementation should be defined and extended independently from each other.
A compile-time binding between an abstraction and its implementation should be avoided so that an implementation can be selected at run-time.
Solution
Separate an abstraction from its implementation by putting them in separate class hierarchies.
Implement the Abstraction in terms of an Implementor object.
Advantages
✅ Provides a flexible alternative to subclassing.
Disadvantages
❌ Introduces an additional level of indirection.
Last updated