Mediator pattern
medium 45 minThe Mediator pattern puts the rules of how a group of objects works together into one object in the middle.
Watch lesson4:27
Where it shows up
The same pattern appears across everyday software.
Swing ButtonGroup
The documentation calls it a multiple-exclusion scope: turning on one button turns off all others in the group. The buttons do not know each other.
HTML radio groups
Radio inputs with the same name form a group in which only one can be selected. The browser is the middle.
Angular FormGroup
Tracks the value and validity of a group of controls. It calculates its status from its children, so a button needs to ask only the group.
Socket.IO rooms
A room is a channel that sockets join and leave, used to broadcast to a subset of clients. Rooms exist on the server only: clients do not have the list.
IRC and XMPP multi-user chat
RFC 1459 and XEP-0045 describe rooms or channels through which users exchange messages. The room also controls who may enter and speak.
Kubernetes API server
The documentation speaks of a hub-and-spoke API pattern. All API usage from nodes ends at the API server.
MediatR for .NET
A simple mediator implementation: in-process messaging for requests, commands and notifications. A request finds its handler without a reference between the two classes. The rules stay in the handlers, so it is closer to a dispatcher.
Spring DispatcherServlet
A front controller: it receives requests and works together with handler mappings, adapters and view resolvers that do not know each other.
Home Assistant
Devices and integrations do not call each other. They meet at an event bus, a state machine and a registry of actions, and automations hold the rules between them.
Air traffic control
A controller gives instructions to each aircraft. The FAA's manual also describes airports without a working tower, where pilots announce themselves, and TCAS, which works between aircraft.