Design pattern----Chain of responsibility (duty chain) mode
Source: Internet
Author: User
Design Patterns----Chain of responsibility (Responsibility Chain)ModeGOF:Enables multiple objects to have the opportunity to process requests, thereby avoiding coupling between the sender and receiver of the request. Connect the objects into a chain and pass the request along the chain until an object handles it. Chain of responsibility (responsibility chain) mode is actually quite simple. In layman's terms, when a request is sent to me, I can deal with it, and I can't handle it and push it to someone else to handle it. That is, the object that accepts the request forms a chain, and the request is passed on the chain until an object on the chain decides to process the request. The customer who issued the request can dynamically rearrange the chain and assign responsibility without affecting the client. Can also understand this, you go to a place to do a thing, originally very small things, but the people shifting, a push one, finally have a heart good person to do things to you. The following is a simple example: The following is a UML diagram: reference: GOF "design mode" by GOF "" in Patterns "by Bruce Eckel" design mode "by Banqiao people http://zhenyulu.cnblogs.com/ articles/65850.html package chainofresponsibility;
Public abstract class Handler
... {
protected Handler successor;
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.