Mediator Pattern

Summary

  • The Mediator pattern enables objects to communicate without knowing each other's identities.
  • The Mediator pattern is used in many modern systems that reflect a send/receive protocol.
  • The Mediator pattern can have a performance impact on a system because all communication must go through the mediator and it can become a bottleneck.

Class diagram: (see Mediator Pattern code review)

Mediator Pattern class diagram of sample code download

Usage

Use the Mediator pattern when:

  • Objects communicate in well-structured but potentially complex ways.
  • The objects identities should be protected even though they communicate.
  • Some object behaviours can be grouped and customized.