Intention
Enables multiple objects to have the opportunity to process the request, thus avoiding the coupling between the sender and the recipient of the request. Connect the objects into a chain and pass the request along this chain until an object can handle the request.
Scene
Suppose we are making a game of customer service system, customer service has three kinds of roles, namely ordinary customer service, customer service Manager and customer service director. Players in the site after questioning, according to the classification and importance of the problem process is different. The rules are as follows:
Issues classified as 1 (game issues) and 2 (role issues) will be handled by ordinary customer service.
The questions that are classified as 3 (recharge issues) and 4 (account issues) will be handled by the customer service Manager.
L The General customer service and the customer Service Manager are not able to deal with the issue by the customer service Director to deal with.
L All problems are divided into common problems and important issues, if the problem is important to the first level of customer service to audit (ordinary customer service response to the problem needs of customer Service Manager Audit, customer Service Manager to answer the questions required by the Customer Service Director audit).
The business rules of this process are complex, and you may think of creating three specific customer service types to inherit abstract customer service, and then pass on the nature of the problem to different customer service to deal with. But there are several drawbacks to doing so:
L clients need to know the problem attributes that three roles can handle, and three roles can handle problems with only three characters that are clear to them.
The L client needs to be coupled with three roles and will invoke different roles in one process. Ordinary customer service after replying to important questions should inform the customer Service Manager to audit, now this process to the client to do
The client knows too many details of customer service handling issues, for players he only needs to know how to tell the customer service staff and get the results of the customer service staff, the specific process behind the process is what kind of it do not know. Therefore, the responsibility chain model is introduced to solve these problems.