the intent of the Bridge pattern is to "De-couple an abstraction from its implementation so that the two can vary independently."
The Bridge pattern separates variations in abstraction and implementation to solve the class explosion problem.
Using design patterns will help you move along this learning curve more quickly. It involves a transition from using a different specialization for each variation (inheritance) to moving these variations into used or owned objects (composition).
Commonality analysis is the search for common elements that helps us understand how family members are the same.Variability analysis reveals how family members vary. Variability only makes sense within a given commonality. The common concepts will be represented by abstract classes. The variations found by variability analysis will be implemented by the concrete classes
There are two basic strategies to follow in creating designs to deal with the variations:
-
Find what varies and encapsulate it.
-
Favor composition over inheritance.
In the past, developers often relied on extensive inheritance trees to coordinate these variations. However, the second strategy says to try composition when possible. The intent of this is to be able to contain the variations in independent classes, thereby allowing for future variations without affecting the code. One way to do this is to have each variation contained in its own abstract class and then see how the abstract classes relate to each other.
The Bridge Pattern: Key Features
|
note : the abstraction and implementation are not the same as the abstract class and the implemented class.