By WalkingTree October 28th, 2020
Chain of Responsibility (COR), also known as Chain of Command, is a behavioral design pattern wherein its primary purpose is to rework the basic workflow and split it into different parts or objects. The Chain of Responsibility allows reordering, adding, and removing handlers in the chain. Also, each handler can be implemented in a way that it could decide whether to pass the request further down the chain or not.
A typical COR structure consists of:
- Handler: It defines the interface for handling requests.
- BaseHandler: An abstract class that contains the boilerplate code which is common to all the handler classes.
- ConcreteHandlers: Contains the actual code.
- Client: It composes the chain of handlers and later initiates the request to a ConcreteHandler object.
When to use Chain of Responsibility in Flutter?
The COR design pattern should be used when the system has to process different kinds of requests. But neither the request types nor the handling sequence is defined at compile-time. The COR pattern enables linking several handlers into one chain and allows the client to pass requests along the chain. Each handler receives the request and processes it.
This pattern can also be used when a single request must be handled by multiple handlers. In such a case, the chain could be defined at compile-time and all requests will get through the chain as planned.
Read on to know more about the Chain of Responsibility design pattern and how it can be implemented in a Flutter framework.
In recent times, due to the effects of the pandemic, a mask detecting app is in great need….
Theming is styling an application so that its look and feel matches your personal design aesthetic or that…
In this blog, we have collated the important Flutter best practices that should be kept in mind for…
In the last blog and webinar on State Management in Flutter, we learned about managing state using Stateful…
In this week’s blog on plugins, we will look at a very special requirement – OCR(Optical Character Recognition)…