Mediator

Design Pattern

Mauricio M.

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

Behavioral

Class Diagram

Real World Example

Use Cases

  • Chat Rooms and communication in general (when we need to isolate objects from each other)
  • UI elements

PROS

  • You can extract the communications between various components into a single place, making it easier to comprehend and maintain.
  • You can introduce new mediators without having to change the actual components.
  • You can reduce coupling between various components.
  • You can reuse individual components more easily.

CONS

  • Over time a mediator can evolve into a God Object.
Made with Slides.com