Broker Mode (mediator) Notes

Source: Internet
Author: User

Mediator Mode (mediator pattern): defines a mediation object to encapsulate the interaction between series objects. The mediator makes the objects not need to be referenced to each other, so that they are loosely coupled and can change their interactions independently.

class Diagram :

Mediator An abstraction that allows colleague to interact with each other
Colleague Customizing the rules for interacting with each other
Coretemediator Specifically implement colleague how they interact
Concretecolleague Specific implementation of the various systems of interaction

Colleague representative (X): When sending notifications, do not need to care to send to someone, but some people know that X is sent to make certain actions. Some of the people you need to notify are responsible for this part of the logic given to mediator.

Usage:

Two UI (A, B), a sets some background colors, and the second updates the background color immediately.   So you do not have a reference to B directly, call B to update the color ();   Instead, call B through the middle of the mediator. A/b more public operations between colleague, mediator is very important to show. There will be no redundant code scattered across the system.

Broker Mode (mediator) Notes

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.