Pattern Comparison

A similarity between the Chain of Responsibility and the Command patterns is that they decouple senders and receivers, thus improving the layering and reusability of a system. The Chain of Responsibility pattern supports decoupling by passing a request between potential receivers, whereas the Command pattern supports using a command object to encapsulate a request. The implementation issues are described in Table 8-1.

Table 8-1. Comparison of 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

Action, in a receiver

Decisions based on

Limits in handlers

Routing in commands

Deals with unimplementable requests

Yes

Yes

Get C# 3.0 Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.