📢 This article was translated by gemini-2.5-flash
Bridge Pattern: Object Structural Pattern
Intent
Separate an abstraction from its implementation so that both can vary independently.
Structure

Where:
- Abstraction: Defines the abstract class interface. It maintains a pointer to an object of type Implementor.
- RefinedAbstraction: Extends the interface defined by Abstraction.
- Implementor: Defines the interface for implementation classes. This interface doesn’t have to be exactly the same as Abstraction’s interface; in fact, the two interfaces can be completely different. Generally, the Implementor interface provides only basic operations, while Abstraction defines higher-level operations based on these primitives.
- ConcreteImplementor: Implements the Implementor interface and defines its concrete implementation.
Applicability
The Bridge pattern is useful when:
- You don’t want a fixed binding between an abstraction and its implementation. For example, the implementation might need to be selected or switched at runtime.
- Both the class abstraction and its implementation should be extensible via subclassing. The Bridge pattern allows developers to combine different abstract interfaces and implementations, and extend them independently.
- Changes to an abstraction’s implementation should not affect clients. Client code shouldn’t need recompiling.
- (C++) You want to completely hide the abstraction’s implementation from clients.
- You have a class hierarchy with many classes to generate.
- You want to share an implementation among multiple objects (possibly using reference counting), but without the client knowing about it.
Example
| |