Wiki Home

Bridge Pattern

(Updated: 1999.10.21 10:24:41 PM)
Namespace: SoftwareEng
Bridge Pattern is one of the 23 Design Patterns elucidated in the most excellent Gamma And Helm book, Design Patterns: Elements of Reusable Object - Oriented Software by Gamma and Helm et al. ISBN 0201633612 , which is cited below:
Intent: Decouple an abstraction from its implementation so that the two can vary independently. (Also known as Handle/Body)

Design Pattern Classification: Structural Object

Applicability:
Use the Bridge pattern when: Structure:

Participants: Collaborations: Consequences:
The Bridge pattern has the following consequences:

1. Decoupling interface and implementation. An implementation is not bound permanently to an interface. The implementation of an abstraction can be configured at run-time. It's even possible for an object to change its implementation at run-time.

Decoupling Abstraction and Implementor also eliminates compile-time dependencies on the implementation. Changing an implementation class doesn't require recompiling the Abstraction class and its clients. This property is essential when you must ensure binary compatibility between different versions of a class library.

Furthermore, this decoupling encourages layering that can lead to a better-structured system. The high-level part of a system only has to know about Abstraction and Implementor.

2. Improved extensibility. You can extend the Abstraction and Implementor hierarchies independently.

3. Hiding implementation details from clients. You can shield clients from implementation details, like the sharing of implementor objects and the accompanying reference count mechanism (if any).

Related Patterns:
An Abstract Factory can create and configure a particular Bridge.

The Adapter Pattern is geared toward making unrelated classes work together. It is usually applied to systems after they're designed. Bridge, on the other hand, is used up-front in a design to let abstractions and implementations vary independently.

See article: http://www.stevenblack.com/PTN-Bridge.asp
See also: VFP Design Pattern Catalog
Category Design Patterns