Mediator pattern, used to handle complex communications between related objects, helping with decoupling of those objects.
Mediator in the Real World
An airport control tower is an excellent example of the mediator pattern. The tower looks after who can take off and land - all communications are done from the airplane to control tower, rather than having plane-to-plane communication. This idea of a central controller is one of the key aspects to the mediator pattern.
When Would I Use This Pattern?
The mediator is a good choice of pattern when the
communication between objects is complicated, but well defined. When there are
too many relationships between the objects in your code, it's time to think of
having such a central point of control.
An observer based variation of the mediator pattern is
used in Java Message Service (JMS) implementations, which allows applications
to subscribe and publish data to other applications. This is a common
combination of patterns that makes sense.
No comments:
Post a Comment