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.
Data represented in a tabular format is easy to understand and interpret. Tabular data also makes effective use…
In this blog series, we started with an introduction to Dart and Flutter. We discussed the reasons for…
Getting started with Flutter can get incredibly easy and successful. Given the increasing demand and everything that is…
Adobe XD is a very fast emerging prototyping application and is making rounds in every organization, who is…
Digital disruption has taken our world by storm and there is still a lot more to explore out…