No nonsense C # design pattern 17: Chain of Resp

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.