Design patterns implementation examples

Chain of resposibility

Definition:

A reqest is sent to an object and if that object can't handle it it sends the request to another object in the chain that may be able to handle it. Separates sender of a request from request's receiver.


Example:

A client comes to a company with an order to perform some work. A worker which talks to the client does not have proper qualifications to perform the work, he just receives the order, therefore he send it to the company's director and then the director sends it to worker who will be responsible for the work.


C++ code:

/src/chainofresponsibility.cpp
Download source code

Chain of resposibility UML class diagram:
Chain of resposibility UML class diagram

Chain of resposibility UML sequence diagram:
Chain of resposibility UML sequence diagram