Bridge
Separates an object’s interface from its implementation.
In Bridge pattern, there are two parts Abstraction and Implementation.
This pattern allows Abstraction and Implementation to be developed independently.
Client will have only access to the Abstraction part without being concerned about Implementation part.
Bridge pattern separates the Abstraction hierarchy and Implementation hierarchy in two different layers, so that change in one hierarchy will not affect the development or functionality of another hierarchy.
Explanation of Example:
In our example code the Abstraction represents Input devices and the Implementer represents Output devices.
Gestures (finger movements) and the Mouse are very different input devices, but their actions map to a common set of output instructions: click, move, drag, etc.
Screen and Audio are very different output devices, but they respond to the same set of instructions. Of course, the effects are totally different, that is, video updates vs. sound effects.
The Bridge pattern allows any input device to work with any output device.
Last updated
Was this helpful?