In continuation with the series on design pattern, in which presently I
going through Behavioral Patterns, today I will write about the Chain of
Responsibility Pattern. You can read about rest of the patterns from the
The Chain of Responsibility pattern deals with a list of Handler objects
that limits based on the requests that they can deal with. If one object
can not handle a request, then the request is passed to the next object
in the chain which means by the end of the chain there can be an
expected behavior or an exception.
The following example is based on the example provided in the DoFactory
As seen in the example there are 3 approvers for withdrawal as a chain.
The request is passed to the clerk and based on the amount the
responsibility is transferred to the successive approver in the chain.
We can use the chain of responsibility patter when we have more than one
handler for a single request or we have a set of handler that vary
In my next post I will be writing about the Command pattern.