Chapter    21

The Mediator Pattern

The mediator pattern is used to simplify and rationalize the communication between groups of objects. This is one of the least well-known design patterns, but it solves a common problem and can simplify the design of an application significantly. Table 21-1 puts the mediator pattern into context.

Table 21-1. Putting the Mediator Pattern into Context

Question

Answer

What is it?

The mediator pattern simplifies peer-to-peer communication between objects by introducing a mediator object that acts as a communications broker between the objects.

What are the benefits?

Instead of having to keep track of and communicate with of all of its peers individually, an object just deals with the mediator.

When should you use this ...

Get Pro Design Patterns in Swift now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.