C # object-oriented model design lecture 20th: chain responsibility chain model (Behavior Model)

Source: Internet
Author: User

(According to the msdn webcast courses)

In some cases, the request recipients may be diverse and changing, as shown in:

Request senders need to maintain multiple coupling to process the transmission of request information. There are multiple strong coupling.

Gof: Enables multiple objects to process requests, so as to avoid coupling between request senders and receivers. These objects are connected into a chain and requests are transmitted along the chain, until an object processes it.

The data structure of a one-way linked list is composed of multiple handler subclasses, And the next Pointer Points to its successor element. When handler cannot process the passed request, it will pass the request to the next handler object until the last one. The next attribute is used to maintain the transfer chain.

You can use the next attribute of handler to dynamically modify the transfer order of the chain at runtime:

Handler2.next = handler3;

Handler3.next = handler1;

<End>

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.