Html/Javascript widget

Tuesday 6 September 2022

Bridge Pattern

The bridge pattern is a design pattern used 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 and what it does vary often. The class itself can be thought of as the abstraction and what the class can do as the implementation. The bridge pattern can also be thought of as two layers of abstraction.

A Variant of this pattern is an implementation that can be decoupled even more by deferring the presence of the implementation to the point where the abstraction is utilized.

Overview

    problems that the Bridge design pattern can solve
  • An abstraction and its implementation should be defined and extended independently from each other.
  • A compile-time binding between an abstraction and its implementation should be avoided so that an implementation can be selected at run-time.
    What solution does the Bridge design pattern describe?
  1. Separate an abstraction (Abstraction) from its implementation (Implementor) by putting them in separate class hierarchies.
  2. Implement the Abstraction in terms of (by delegating to) an Implementor object.

No comments:

Post a Comment