Introduction to mediator pattern of Java design pattern
Mediator definition: a mediation object is used to encapsulate a series of object interaction behaviors.
Why use mediator mode / mediation mode
There are many interactive operations among objects. The behavior operations of each object depend on each other. Modifying the behavior of one object will also involve modifying the behavior of many other objects. If mediator mode is used, the coupling between objects can be loose. Only the relationship with mediator needs to be concerned, so that the many to many relationship becomes a one to many relationship, It can reduce the complexity of the system and improve the modifiability and scalability.
How to use mediation mode
First, there is an interface to define the interaction between member objects: