基本概念
Bridge Pattern: Decouple an abstraction from its implementation so that the two can vary independently.
实现代码
抽象部分
Abstraction
精确抽象
Refined Abstraction
实现部分
Implementation
具体实现
Concrete Implementations
Q & A
What are key advantages of using a bridge design pattern?
The implementations are not bound to the abstractions. Both the abstractions and the implementations can grow independently.
Why sometimes bridge pattern is confused with the adapter pattern?
They both serve as a structural liaison between two distinct interfaces or systems.
However, the key purpose of an adapter pattern is to deal with incompatible interfaces only, while an adapter pattern is to deal with incompatible interfaces only while the Bridge pattern is designed to separate the abstraction from its implementation, allowing both to vary independently without affecting each other.
The Adapter makes things work after they are designed;
The Bridge makes them work before they are.