When to use CQRS
Why would you want to use the mediator or the CQRS patterns? There are a lot of reasons for sure, but we will only go over the apparent reasons, which are as follows:
- Services call each other: All the read and write requests go into the box in the middle (the mediator) and then come out. If you want to trigger any request from anywhere, the request has to hit the box in the middle, the mediator.
- Clean code in large projects: The use of the mediator and mediator pipelines will help you shrink your controller sizes and move your business logic into their respective files. Hence, it will be effortless to traverse the folder structure and find the logic you're looking for.
- A boundary between writes and reads: Any UI team can efficiently implement a UI that requires more data from the database due to the separation of reads and writes.
A UI team can work freely without worrying about affecting the backend work and how logic may distribute notifications...