Mediator and Chain of Responsibility
Explore two behavioral patterns that decouple senders from receivers: Mediator centralizes communication, and Chain of Responsibility passes requests along a line of handlers.
Two Ways to Decouple Communication
Objects often need to talk to each other, but direct references create tangled webs of dependencies.
This lesson covers two behavioral solutions:
- Mediator routes all communication through a central hub.
- Chain of Responsibility passes a request down a line until someone handles it.
The Mediator Problem
Imagine a dialog with buttons, checkboxes, and text fields all reacting to each other. If every widget references every other widget, the coupling explodes.
Mediator replaces this mesh with a star: each widget talks only to the mediator.
All lessons in this course
- Observer and Strategy Patterns
- Command and Iterator Patterns
- Template Method and State Patterns
- Mediator and Chain of Responsibility