Mediator is a behavioral design pattern that reduces coupling between components of a program by making them communicate indirectly, through a special mediator object.
The Mediator makes it easy to modify, extend and reuse individual components because they are no longer dependent on the dozens of other classes.
Application of the pattern in C#
Usage examples: The most popular usage of the Mediator pattern in C# code is facilitating communications between GUI components of an app. The synonym of Mediator is Controller part of MVC pattern.
Example: Structure of the Pattern
This example illustrates the structure of the Mediator design pattern. It focuses on answering these questions:
- What classes does it consists of?
- What roles do these classes play?
- In what way the elements of the pattern are related?
Program.cs: Structural Example