
162
CMSC 433 – Programming Language
Technologies and Paradigms
Spring 2004
Design Patterns
March 4, 2004
163
Multiple Window Systems
•Want portability to different window systems
–Similar to multiple look-and-feel problem, but different
vendors will build widgets differently
•Solution:
–Define abstract class Window, with basic window
functionality (e.g., draw, iconify, move, resize, etc.)
–Define concrete subclasses for specific types of
windows (e.g., dialog, application, icon, etc.)
–Define WindowImp hierarchy to handle window
implementation by a vendor
165
Bridge Pattern
• Name
–Bridge or Handle or Body
•Applicability
–Handles abstract concept with different implementations
–Implementation may be switched at run-time
–Implementation changes should not affect clients
–Hide a class’s interface from clients
•Structure: use two hierarchies
–Logical one for clients,
–Physical one for different implementations
166
Structure of Bridge Pattern
167
Bridge Pattern
•Consequences:
–Decouple interface from implementation and
representation
–Change implementation at run-time
–Improve extensibility
•Logical classes and physical classes change independently
•Hides implementation details from clients
–Sharing implementation objects and associated reference counts