Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mediator

1,072 views

Published on

Mediator pattern

Published in: Technology
  • Login to see the comments

Mediator

  1. 1. Mediator pattern
  2. 2. Intent ● Define an object that encapsulates how a set of objects interact. ● Design an intermediary to decouple many peers. ● Promote the many-to-many relationships between interacting peers
  3. 3. Problem ● dependencies between the potentially reusable pieces demonstrates the "spaghetti code" phenomenon.
  4. 4. Motivation ● By consolidating all interaction in a single class, we can regain elegance and reusability.
  5. 5. UML
  6. 6. Examples
  7. 7. Pros & Cons Pros: ● Decouples colleagues, which facilitates independent variations of the colleague and mediator classes. ● Simplifies protocol by replacing many-to-many interaction with one-to-one interaction Cons: ● Reducing the complexity of Colleagues increases the complexity of the Mediator itself.
  8. 8. Related patterns ● Observer: the Mediator class may be implemented using an Observer ● Facade: is similar to a Mediator, but with one- way communication from the Facade to its subsystem classes..

×