LearningTech

Behavioral

Mediator

Description

Lets you reduce chaotic dependencies between objects. The pattern restricts direct communications between the objects and forces them to collaborate only via a mediator object.

Where to use

  • Chat rooms.
  • \n
  • GUI forms with complex interactions.

Real World Example

Air Traffic Control. Planes don't talk to each other; they talk to the Tower, which coordinates them.

Code Example

class Mediator:
    def __init__(self):
        pass

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