Design Pattern - Bridge (Structural) : References
Design Pattern - Bridge (Structural) : References
Design Pattern - Bridge (Structural) : References
(Structural)
References
Yih-shoung Chen, Department of Information Engineering, Feng Chia
University,Taiwan, R.O.C.
The Bridge Pattern, SENG 609.04 Design Patterns, University of Calgary
By Tulika Rathi
2
Motivation & Applicability
Avoid a permanent binding between an
abstraction and its implementation
Both the abstractions and their implementation
should be extensible by subclassing
Changes in the implementation of an abstraction
do not impact the clients
Share an implementation among multi objects and
this facts should be hidden from the client
E.g.: Windows
By Tulika Rathi
3
Participants
Abstraction
Refined abstraction
Concrete implementor
Implementor
By Tulika Rathi
4
Structure
By Tulika Rathi
5
Example of problem suitable for bridge
By Tulika Rathi
6
A more complex situation
By Tulika Rathi
7
Solution using Bridge
By Tulika Rathi
8
Pros & Cons
Pros
decoupling of the implementation from the interface
improved extensibility of classes
additional capability for hiding implementation details from
clients
best leveraged as a pure design-time pattern
Cons (Implementation Issues)
abstractions that have only one implementation
creating the right Implementor
sharing implementors
use of multiple inheritance
By Tulika Rathi
9
Adapter vs Bridge
Similarities:
Both used to hide the details of the underlying implementation.
Difference:
The adapter pattern is geared towards making unrelated components work
together
Applied to systems after they’re designed (reengineering, interface
engineering).
A bridge, on the other hand, is used up-front in a design to let abstractions
and implementations vary independently.
Green field engineering of an “extensible system”
New “beasts” can be added to the “object zoo”, even if these are not
By Tulika Rathi
10
Thank You