桥接(Bridge)
Intent
将抽象与实现分离开来,使它们可以独立变化。
Class Diagram
- Abstraction:定义抽象类的接口
- Implementor:定义实现类接口
Implementation
RemoteControl 表示遥控器,指代 Abstraction。
TV 表示电视,指代 Implementor。
桥接模式将遥控器和电视分离开来,从而可以独立改变遥控器或者电视的实现。
1 | public abstract class TV { |
1 | public class Sony extends TV { |
1 | public class RCA extends TV { |
1 | public abstract class RemoteControl { |
1 | public class ConcreteRemoteControl1 extends RemoteControl { |
1 | public class ConcreteRemoteControl2 extends RemoteControl { |
1 | public class Client { |
JDK
- AWT (It provides an abstraction layer which maps onto the native OS the windowing support.)
- JDBC