Orchestrating commands and queries
Rule of thumb
Encapsulate comand and queries behavoirs in use-case modules.
In previous posts, I mentioned different modules such as Services, Repositories, Helpers… Each one has a role to play, but we need them all to interact in order to achieve meaningful feature behavior — a command or a query.
A Use-case is a module that orchestrates multiple modules into a single logical flow. In other words, use-cases implement the high-level behavior of a system subdomain.
For example, our Auth
a subdomain is required to provide features such as:
- Registering a user
- Login
- Reset password
Each of these flows is a use-case. It doesn’t matter how it is triggered, from an API, or a CLI, the behavior is the same.