Saturday, September 15, 2007

Chain of Responsibility



definition
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
The classes and/or objects participating in this pattern are:
Handler (Approver)
defines an interface for handling the requests
(optional) implements the successor link
ConcreteHandler (Director, VicePresident, President)
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 (ChainApp)
initiates the request to a ConcreteHandler object on the chain

No comments:

Design Principle

  • DIP
  • SRP