Bridge Pattern

The bridge pattern is a design pattern used in software engineering which is meant to "decouple an abstraction from its implementation so that the two can vary independently". The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.

When a class varies often, the features of object-oriented programming become very useful because changes to a program's code can be made easily with minimal prior knowledge about the program. The bridge pattern is useful when both the class as well as what it does vary often. The class itself can be thought of as the implementation and what the class can do as the abstraction. The bridge pattern can also be thought of as two layers of abstraction.

The bridge pattern is often confused with the adapter pattern. In fact, the bridge pattern is often implemented using the class "adapter pattern", e.g. in the Java code below.

Variant: The implementation can be decoupled even more by deferring the presence of the implementation to the point where the abstraction is utilized.

Read more about Bridge Pattern:  Structure

Famous quotes containing the words bridge and/or pattern:

    Home! Yes! she would see Trafalgar Square, again; and Nelson on his plinth; and Chelsea Bridge as it dissolved into the Thames at twilight ... and St. Paul’s, the single Amazon breast of her beloved native city.
    Angela Carter (1940–1992)

    With only one life to live we can’t afford to live it only for itself. Somehow we must each for himself, find the way in which we can make our individual lives fit into the pattern of all the lives which surround it. We must establish our own relationships to the whole. And each must do it in his own way, using his own talents, relying on his own integrity and strength, climbing his own road to his own summit.
    Hortense Odlum (1892–?)