Overview
The Mediator design pattern is a behavioral pattern that promotes loose coupling between objects by defining a mediator object that encapsulates how these objects interact with each other. In this pattern, objects communicate with each other through the mediator object instead of directly communicating with each other. The mediator object acts as a hub, facilitating communication between objects and managing their interactions.
So instead of ending with the component design in which every component needs to know about every other component:
The Mediator is used to promote decoupling and keep operations that involve multiple components in one place. That way, each component needs to be aware of the Mediator but does not need to know every other component in the system. So, for example, when writing a GUI application, it is common for one operation to update multiple components (title, textbox, list). Using the Mediator, we can end up with a design in which each component is decoupled – components do not know about each other, but the driving component invokes an operation from the Mediator, which then invokes driven components from each update operation that is required.
More on this pattern…
To read more on this and the other patterns, get “GoF Design Patterns Distilled” book from Amazon or Leanpub: