Design Patterns in the Test of Time: Bridge
Join the DZone community and get the full member experience.
Join For Free
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.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments