5/27/2011

Chain of Responsibility Pattern

Chain of responsibility patterns is used when we want to divide a control logic into pieces. The most common implementation is an email handler mechanism. In this mechanism, we will have an Handler interface and some classes implementing this Handler interface.


All requests will come to the first handler. After the first handler handles the requests whose rules are defined in its class, it will pass the control (remaining requests) to second handler. This flow will continue until all requests handled.

Sort the handlers from the most used to the least. By this way, unnecessary or least used ones will not work so often.


Ref: Head First Design Patterns

No comments:

Post a Comment