Mediator design pattern
Let's continue with the Mediator pattern. As its name implies, it's a pattern that will be in between two types to exchange information. But, why will we want this behavior at all? Let's look at this in detail.
Description
One of the key objectives of any design pattern is to avoid tight coupling between objects. This can be done in many ways, as we have seen already.
But one particularly effective method when the application grows a lot is the Mediator pattern. The Mediator pattern is the perfect example of a pattern that is commonly used by every programmer without thinking very much about it.
Mediator pattern will act as the type in charge of exchanging communication between two objects. This way, the communicating objects don't need to know each other and can change more freely. The pattern that maintains which objects give what information is the Mediator.
Objectives
As previously described, the main objectives of the Mediator pattern are about loose coupling and encapsulation...