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