Dr. Yan Hong's book "Java and patterns" describes the mediator mode in this way:
The mediator mode is the behavior mode of objects. The Paster mode encapsulates a series of object interaction methods so that these objects do not need to be explicitly referenced to each other. So that they can be loosely coupled. When the interaction between some objects in these objects changes, the interaction between other objects is not immediately affected. This ensures that these interactions can change independently.
Why do users need to be redeployed?
As shown in, there are a large number of objects. These objects affect other objects and are affected by other objects. Therefore, they are often called colleags. These colleagues interact with each other to form systematic behavior. It can be seen that almost every object needs to interact with other objects, and this interaction represents a direct coupling between an object and another object. This is an over-coupled system.
By introducing a mediator object, you can change the system's mesh structure to a star structure centered on the intermediary, as shown in. In this star structure, the colleague object no longer interacts with another object through direct connections; on the contrary, it interacts with another object through the mediator object. The existence of the Mediator object ensures the stability of the object structure. That is to say, the structure of the system will not be greatly modified because of the introduction of new objects.
A good object-oriented design can increase collaboration between objects and reduce couping ). A well-thought-out design Splits a system into a group of cooperative colleagues, and then gives each colleague an unique responsibility to properly configure the collaboration relationship between them, so that they can work together.
If no motherboard exists
As we all know, the interaction between various accessories in the computer is mainly completed through the motherboard. If no motherboard exists in the computer, each accessory must interact with each other to transmit data to each other. In addition, because the interfaces of each accessory are different, data interfaces must be converted to match each other during interaction.
Fortunately, with the motherboard, the interaction between each accessory is completely completed through the motherboard. Each accessory only needs to interact with the motherboard, And the motherboard knows how to deal with all the accessories, this is much simpler.