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:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>