Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Mediator A Behavioral Design Pattern for the New Millennium Cory Nugent."— 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.


Download ppt "Mediator A Behavioral Design Pattern for the New Millennium Cory Nugent."

Similar presentations


Ads by Google