LearningTech

Structural

Bridge

Description

Splits a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently.

Where to use

  • Cross-platform apps.
  • \n
  • Decoupling interface from device.

Real World Example

A 'RemoteControl' (Abstraction) works with a 'TV' (Implementation). You can add new Remotes or new TVs without breaking each other.

Code Example

class Bridge:
    def __init__(self):
        pass

    def execute(self):
        print('Executing Bridge')