Discussing about a CQRS implementation with my team we don’t agree on a point concerning the Query side.
On the Commad side we have actual command clases; a
CommandDispatcher that schedules commands, defines a Unit of Work scope and dispatches commands to handlers; handlers that contain the business logic and do CRUD operations using repositories.
For the Query side the team is split on two:
- One part of the team says that a simple read service layer is enough, services that access directly the data source (no repositories) and can be called directly from callers (no query classes nor a query dispatcher).
- The other part of the team says that we should build the Query side symmetrically to the Command side, having query classes, a query dispatcher and fetch data from repositories.
We don’t need any synchronization nor scheduling system for queries (query dispatcher) and query handlers must be mostly classes that return data fetched from repositories. So we would add potentially unnecessary extra layers only for the sake of symmetry.