The pause mode in Java and Mode

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.