Book Image

Swift 2 Design Patterns

By : Julien Lange
Book Image

Swift 2 Design Patterns

By: Julien Lange

Overview of this book

Table of Contents (15 chapters)
Swift 2 Design Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...