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

Comparison between the chain of responsibility and command patterns


The difference between the two patterns is the way in which the request is decoupled.

In the chain of responsibility pattern, the request is passed to potential receivers, whereas the command pattern uses a command object that encapsulates a request.

The following table describes the difference between the chain of responsibility and command patterns:

 

Chain of responsibility

Command

Client creates

Handler objects

Command objects

Different kinds of

Handler classes at different levels

Command classes and receiver classes

Client can work with

Multiple handlers

Different receivers

Client calls

Handler objects

Receiver objects

Work is done in

HandleRequest in a handler

ActionToPerform in a receiver

Decision based on

Mask in handlers

Routing in commands