As the name implies, the Chain of Responsibility Pattern creates a chain of recipient objects for the request. This mode gives the type of request and decouples the sender and receiver of the request. This type of design pattern is a behavioral pattern.
In this model, usually each recipient contains a reference to another recipient. If an object cannot handle the request, it will pass the same request to the next recipient, and so on.
Source Address: https://www.runoob.com/design-pattern/chain-of-responsibility-pattern.html
simulate what the mall is a simple process to encapsulate the chain of responsibility
to create a pipeline (process)
an abstract method to define the pipeline
again Create a node and
rewrite the method to achieve the purpose of each process.
Then create a new linked list.
Adding a node is equivalent to three different pipes in
a water pipe. A glass of water must flow through the three pipes that we set.
Next Run
This simple chain of responsibility is completed.
Next, let’s talk about my views on the chain of responsibility:
- It is a chained execution scheme. It is a black box.
You don’t need to know what’s in it. You don’t need to know what’s in it. You don’t need to know what’s in it. Just input something and let it go through these processes to get what you want. - It can perform mutual transformations. The nodes change positions each other. It can be executed completely. No matter adding nodes or deleting nodes, it will not affect
. Several nodes in it can be combined at will. - Everyone who uses this chain of responsibility will perform exactly the same sequence of operations
Thanks for watching, your support is the biggest motivation for my creation~~