Summary

A comparison between the mediator pattern and the observer pattern shows some of the similarities and differences. Both patterns facilitate the communication between the objects and both decouple the link between the sender and the receiver. The main difference is that in the mediator pattern, there is a notion of the participants and they communicate with each other using the mediator as a central hub, whereas in the observer pattern, there is a clear distinction between the sender and the receiver, and the receiver merely listens to the changes in the sender.

The communication in the mediator pattern is easier to understand. Elements send messages to a mediator and the transmission of the information further to whoever is currently in the group is handled there, in one place.

In the observer pattern, observers wait to be invoked with information from more than one subject. The coupling is closer in the mediator than in the observer.

This concludes this chapter. In the last chapter, we will talk about the last three behavioral patterns the: visitor pattern, the interpreter pattern, and the memento pattern.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset