Bridge Mode (Bridge)


GOF intent: to separate the abstract part from its implementation part so that they can both vary independently 

 

Role:

Abstraction role: abstracts the given definition and holds a reference to the realized object.

Revised abstraction (Refined Abstraction) role: extends the abstraction role, changing and revising the parent class's definition of abstraction.

 

Implementor role: This role gives the interface of the implementor role, but does not give a concrete implementation. It must be pointed out that this interface is not necessarily the same as the interface definition of the abstract role, in fact, the two interfaces can be very different. Implementation roles should only give low-level operations, while abstract roles should only give higher-level operations based on low-level operations.

Concrete Implementor role: This role gives the concrete implementation of the Implemented role interface.

 

Implementation points:

A class A ( Abstraction role ) provides a functional interface, another class B ( Implementor role ) provides a method to implement this function, and A holds a reference to B, the relationship between these two classes is a bridge. They can vary independently.

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326831033&siteId=291194637