Responsibility chain Model--headfirst Design Patterns Learning Notes

Source: Internet
Author: User

Responsibility chain mode: Enables more than one object to have the opportunity to handle a request

Characteristics:

    • Each object in the chain contains a reference to its next object and a way to handle the event. The request is passed on this chain until an object on the chain decides to process the request
    • The client making this request does not know which object on the chain is ultimately processing the request, decoupling the sender of the request from the receiver
    • Can dynamically change the order of processing object members, can dynamically increase the reduction of processing objects

Use:

    • More for Windows systems, handling events such as mouse keyboards

Disadvantages:

    • There is no guarantee that the request will be executed
    • Not easy to observe the runtime features, which hinder the troubleshooting

Example:

Different types of messages are handled differently, the customer passes the message to the first processor, and the processor decides 1. Process the message; 2. Pass a reference to the same base class to the next processor

Responsibility chain Model--headfirst Design Patterns Learning Notes

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.