Design Patterns - Bridge

xiaoxiao2021-04-05  250

1. The intent of the BRIDGE pattern is to decouple an abstraction (a class that relies on a set of abstarct operations, GoF Design Patterns) from the implementation of its abstract operation, so that the abstraction and its implementation can vary independently.

2. A Bridge Structure Moves The Abstract Operations That An Abstract Relies On In Into a Separate Interface, PIC:

Implementor Contains The Abstract Operations Seperated from Abstract, And After Seperation Abstract Is Concrete.

3. A Common Example of Bridge Occurs In Drivers Uses A Driver IS An Abstract - The Choice of Driver Determines What Happens When the Application Runs.

4. Steps to Refactor a hierarchy with an abstract class at Lits Top Into a bridge:

a. Move The Abstract Operation in The Superclass Into an interface.

B. DEFINE IMPLEMENTATION CLASS That Provide DiffERENT IMPLEMENTATION OF THE INTERFACE.

C. Redefine The remaining Operations in an in the mentioning Operations Usually Uses The Functions In The interface.

5. Another EXAMPLE OF BRIDGE:

Ori:

Sec. Sec:

After Refactor:

转载请注明原文地址:https://www.9cbs.com/read-132081.html

New Post(0)