Chain of Responsibility


Usage
  • A way of passing a request between a chain of objects
  • Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request
  • Chain the receiving objects and pass the request along the chain until an object handles it
Diagram
Chain of Responsibility
Participants
Handler
  • Defines an interface for handling the requests
  • Optionally implements the successor link
ConcreteHandler
  • Handles requests it is responsible for
  • Can access its successor
  • If the ConcreteHandler can handle the request, it does so; otherwise it forwards the request to its successor
Client
  • Initiates the request to a ConcreteHandler object on the chain