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
Participants
Handler
ConcreteHandler
- Defines an interface for handling the requests
- Optionally implements the successor link
Client
- 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
- Initiates the request to a ConcreteHandler object on the chain
