Bridge

A bridge is like an adapter but it's intention is different. With an adapter you are adapting an existing object's interface to fit your new interface. A bridge decouples an abstraction from its implementation so that the two can vary independently.

When we think about abstraction and implementation we usually think about class hierarchies. In this situation abstractions are implemented by their subclasses. In other words we are using inheritance as a mechanism for implementing our abstraction.

The bridge pattern describes how to implement our abstraction via composition.

Quick Reference

Pattern Name Bridge
Other Names Handle-Body
Classification Object Behavioral
Intent Allows the interface and implementation to vary independently

General Structure

Example

results matching ""

    No results matching ""