1 / 12

Mediator

Mediator. A Behavioral Design Pattern for the New Millennium. Cory Nugent. Designing for OOP. Goals of Object Oriented Design Distribute behavior among different objects. Encourage code reuse Facilitate communication between objects. What’s the Problem?.

annetteg
Download Presentation

Mediator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mediator A Behavioral Design Pattern for the New Millennium Cory Nugent

  2. Designing for OOP • Goals of Object Oriented Design • Distribute behavior among different objects. • Encourage code reuse • Facilitate communication between objects

  3. What’s the Problem? • Communication between objects becomes too complicated. • Changing system behavior becomes too difficult. • No central access points are available.

  4. DAS MEDIATØR! • A class that controls interactions of a group of other objects. • Promotes loose coupling (Objects don’t explicitly reference each other). • Objects need only know about their mediator. • Provides a centralized behavior management point.

  5. The Good • Changing system behavior means sub-classing the mediator. • Mediator and Colleague classes are independent of each other. • Mediator-Colleague relationship is one to many; Colleague-Colleague relationship is many to many. • Object interaction becomes easy to understand.

  6. The Bad • All object interactions are bundled into the mediator. • The mediator class can be complex and hard to maintain.

  7. How it all works Diagram courtesy of Gopalan Suresh Raj

  8. The Mediator • Mediator • Defines an interface for communicating with colleague classes. • Concrete Mediator • Coordinates colleague objects

  9. How it all works Diagram courtesy of Gopalan Suresh Raj

  10. The Colleagues • Colleague • Defines an interface for communicating with mediator class. • Concrete Colleagues • Each colleague knows its mediator • Each colleague communicates with its mediator when it would otherwise communicate with its colleague.

  11. How it all works Diagram courtesy of Gopalan Suresh Raj

  12. There is no more presentation • Thank you, come again.

More Related