2. Intent
Mediator Pattern _ap2
Object Behavioral an object that encapsulates how a
set of objects, which can interact and refer each other
independently.
3. Motivation
Mediator Pattern _ap3
Requirement of system –
A system needs objects to communicate with each other and
should be able to share properties of each other.
Desired system will have –
Different objects which can communicate with each other.
Problem –
Object structure will have many connections between objects
Every object ends up knowing about every other.
4. Applicability
Mediator Pattern _ap4
When one or more objects must interact with several different
objects.
When simple object need to communicate in complex ways.
When you want to reuse an object that frequently interacts with
other objects.
7. Example-Steps
Mediator Pattern _ap7
The list box tells its director that it’s changed.
The director gets the selection from the list box.
The director passes the selection to the entry field.
Director takes action.
9. Participants
Mediator Pattern _ap9
Mediator
-defines an interface for communicating with Colleague
objects.
Concrete Mediator
-implements cooperative behavior by coordinating
Colleague objects.
-knows and maintains its colleagues.
Colleague classes
-each Colleague class knows its Mediator object.
-each colleague communicates with its mediator
whenever it would have otherwise communicated with
another colleague.