flâneur — a map of the web's best reading

Chain of Responsibility

refactoring.guru · 2,570 words · saved by 1 readers

Chain of Responsibility is a behavioral design pattern that lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain. Imagine that you’re working on an online ordering system. You want to restrict access to the system so only authenticated users can create orders. Also, users who have administrative permissions must have full access to all orders. After a bit of planning, you realized that these checks must be performed sequentially. The application can attempt to authenticate a user to the system whenever it receives a request that contains the user’s credentials. However, if those credentials aren’t correct and authentication fails, there’s no reason to proceed with any other checks. The request must pass a series of checks before the ordering system itself can handle it. During the next few months, you implemented several more of those sequential checks. One of your c

/ Design Patterns / Behavioral Patterns Chain of Responsibility Also known as: CoR, Chain of Command Intent Chain of Responsibility is a behavioral design pattern that lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain. Problem Imagine that you’re working on an online ordering system. You want to restrict access to the system so only authenticated users can create orders. Also, users who have administrative permissions must have full access to all orders. After a bit of pl

Explore this link on the map →

related reading