Definition
Decouple an abstraction from its implementation so that the two can vary independently. (Separate implementation of methods to other classes)
UML Class Diagram
Bridge: when and where use it
- The Bridge pattern is used for decoupling an abstraction from its implementation so that the two can vary independently. Bridge is a high-level architectural patterns and its main goal is through abstraction to help .NET developers write better code. A Bridge pattern is created by moving a set of abstract operations to an interface so that both the client and the service can vary independently. The abstraction decouples the client, the interface, and the implementation.
- A classic example of the Bridge pattern is when coding against device drivers. A driver is an object that independently operates a computer system or external hardware device. It is important to realize that the client application is the abstraction. Interestingly enough, each driver instance is an implementation of the Adapter pattern. The overall system, the application together with the drivers, represents an instance of a Bridge.
Sample
- Implementor interface.
- Concrete Implementor class
- Abstraction class (implementor is a part of abstraction class)
- Refined Abstraction class (concrete class of abstraction class)
- Invoke class
Ref: Gang of Four tutorial
No comments:
Post a Comment