added README in ChainOfResponsibilities

This commit is contained in:
Dominik Liebler 2013-09-24 09:49:29 +02:00
parent c64c344f0f
commit fe6127044e
2 changed files with 10 additions and 11 deletions

View File

@ -1,13 +1,12 @@
# chain of responsibilities
# Chain Of Responsibilities
## Purpose:
To build a chain of objects to handle a call. if one object cannot handle a call, it delegates the call to the next
in the chain and so forth
To build a chain of objects to handle a call. If one object cannot handle a call, it delegates the call to the next in the chain and so forth.
## Examples:
* logging framework
* spam filter
Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
* Yii Framework: CFilterChain is a chain of controller action filters. the executing point is passed from one filter to the next along the chain, and only if all filters say "yes", the action can be invoked at last.
* logging framework, where each chain element decides autonomously what to do with a log message
* a Spam filter
* Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
* Yii Framework: CFilterChain is a chain of controller action filters. the executing point is passed from one filter to the next along the chain, and only if all filters say "yes", the action can be invoked at last.

View File

@ -3,14 +3,14 @@
namespace DesignPatterns\ChainOfResponsibilities;
/**
* Request is a request which goes throught the chain of responsibilities.
* Request is a request which goes through the chain of responsibilities.
*
* About the request : Sometimes, you don't need an object, just an integer or
* an array. But in this case of a full example, I've made a class to illustrate
* this important idea in the CoR (Chain of Responsibilities). In real world,
* I recommand to always use a class, even a \stdClass if you want, it proves
* to be more adaptative because a single handler doesn't know much about the
* outside world and it is more difficult if, one day, you want add some
* I recommend to always use a class, even a \stdClass if you want, it proves
* to be more adaptive because a single handler doesn't know much about the
* outside world and it is more difficult if, one day, you want to add some
* criterion in a decision process.
*/
class Request