Design Patterns in the Test of Time: Bridge
The bridge pattern is a design pattern used in software engineering which is meant to "decouple an abstraction from its implementation so that the two can vary independently".The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.
Bridge is quite complex, mostly because it is composed of Abstraction, Refined Abstraction, Implementor and Concrete Implementor. Here is a concrete example (pun intended):
- Abstraction: CImage
- Refined Abstraction: CBmpImage, CJpegImage
- Implementor: CimageImp
- Concrete Implementor: CWinImp, COS2Imp
In general, I don’t like complex things, and of the top of my head, I can’t think of a time when I used this approach. Until such time when I can see a really good reason why I would want to do something like this, I see very little reason to bother.
Recommendation: Avoid, there are simpler options to solving those sort of problems.