Design Patterns of the Chain of Responsibility Pattern (ChainofResponsibility) Introducing the Chain of Responsibility Pattern Examples of the Chain of Responsibility Pattern Analysis of the Chain of Responsibility Pattern Applications of the Chain of Responsibility Pattern
The chain of responsibility model describes how to pass the buck, or to put it succinctly, kick the bucket haha. For example, sometimes, something goes wrong, we go to fix it, we find A, only to have A kick the can down the road and say it's none of my business, go to B and fix it, then we go to B, only to have B also say, it's none of my business, go to C. That's it, we get kicked around, that's the idea of the chain of responsibility model, until we find the right person to fix it, we get kicked around constantly to one and one person, just passing the buck.
The above example, may be a bit pejorative, but in actual programming, there are sometimes situations where we do need to pass the buck,, for example, when we receive a request and the current program is temporarily unable to handle the request, so we need to give the request to someone else to handle. If you are a web developer, you should be familiar with this, when the server receives a request from the client, it will first parse the request, the action layer will not process the request, but will simply parse the request parameters and other information, and then forward the request specifically to the service to process according to the request content information.
When a person is asked to do something, if he can do it himself, then he does it himself, if he can't do it himself, then he forwards it to another person who does the same, if he can do it himself, then he does it, if not, then he gives it to someone else 。。。。。。
This is the basic idea of the chain-of-responsibility model