Mediator: Introduction

Get a brief introduction to the Mediator design pattern.

The Mediator design pattern is where one object facilitates communication between multiple other objects. It’s analogous to air traffic control, a mediator between different flights. Planes can talk to the air traffic control, which then delivers relevant information to other planes. Planes don’t talk to each other directly.

Summarized concept of the Mediator design pattern

The Mediator design pattern can be summarized as follows:

  • There’s a Mediator object to hold a list of Participants and facilitate communication between them.
  • There are multiple Participant objects, which can be of completely different types.
  • When a Participant object wants to send a message to another Participant object, it sends the message to the Mediator object.
  • Based on some parameter that identifies the recipient, the Mediator object sends the message to an appropriate Participant object.

Get hands-on with 1200+ tech skills courses.