The Chain of Responsibility pattern establishes a chain within a system, so that a message can either be handled at the level where it is first received, or be directed to an object that can handle it.
The following lists the benefits of using the Chain of Responsibility pattern:
- Reduced coupling
- Added flexibility in assigning responsibilities to objects
- Allows a set of classes to behave as a whole, because events produced in one class can be sent on to other handler classes within the composite
You should use the Chain of Responsibility pattern when:
- More than one object can handle a request, and the handler isn’t known.
- You want to issue a request to one of several objects without specifying the receiver explicitly.
- The set of objects that can handle a request should be specified dynamically.