Chain of responsibility Mode

Source: Internet
Author: User
Chain of responsibility Mode

The responsibility chain mode is an object behavior mode [gof95 ]. In the responsibility chain mode, many objects are connected by each object's reference to its next home to form a chain. Requests are transmitted on this chain until an object on the chain decides to process this request. The client that sends this request does not know which object on the chain will eventually process this request, which allows the system to dynamically reorganize the chain and assign responsibility without affecting the client.

Starting from drumming and spreading flowers

Drumming is a lively and intense drinking game. At the banquet, guests are arranged in sequence to drum up one person. The drums are separated from the flowers to show justice. When the drum is started, the bouquet begins to pass in sequence, and the sound of a drum falls. If the bouquet is in the hands of someone, the person will have to drink.

It is the application of the responsibility chain model. A responsibility chain may be a straight line, a link chain, or a part of a tree structure.

Structure of the responsibility chain model

 

The roles involved in the responsibility chain mode are as follows:

Abstract handler role: defines an interface for processing requests. If necessary, the interface can define a method to set and return references to the next house. This role is usually implemented by an abstract class or interface.

Concretehandler role: after receiving a request, the handler can choose to process the request or send the request to the next home. Because the specific Handler holds a reference to the next home, if necessary, the specific handler can access the next home.

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.