previous up next Chain of Responsibility

Intent, Motivation, Applicability, Structure, Participants, Collaborations, Consequences, Implementation, Sample Code, Known Uses, Related Patterns

previous next Consequences

Chain of Responsibility has the following benefits and liabilities:

  1. Reduced coupling. The pattern frees an object from knowing which other object handles a request. An object only has to know that a request will be handled ``appropriately.'' Both the receiver and the sender have no explicit knowledge of each other, and an object in the chain doesn't have to know about the chain's structure.

    As a result, Chain of Responsibility can simplify object interconnections. Instead of objects maintaining references to all candidate receivers, they keep a single reference to their successor.

  2. Added flexibility in assigning responsibilities to objects. Chain of Responsibility gives you added flexibility in distributing responsibilities among objects. You can add or change responsibilities for handling a request by adding to or otherwise changing the chain at run-time. You can combine this with subclassing to specialize handlers statically.

  3. Receipt isn't guaranteed. Since a request has no explicit receiver, there's no guarantee it'll be handled---the request can fall off the end of the chain without ever being handled. A request can also go unhandled when the chain is not configured properly.


Consequences of Abstract Factory, Adapter, Bridge, Builder, Chain of Responsibility, Command, Composite, Decorator, Facade, Factory Method, Flyweight, Interpreter, Iterator, Mediator, Memento, Observer, Prototype, Proxy, Singleton, State, Strategy, Template Method, Visitor

previous next