I am trying to understand DDD and CQRS, but I am confused by the idea that commands and queries are part of the domain alongside domain events as messages. Others say that commands and queries are part of the application layer. In both perspectives, only the handlers are seen as part of the application layer. Does this mean that, according to the first perspective, you cannot invoke queries or commands directly from the API/presentation layer and therefore have to wrap this call in an application service? Where should commands and queries be placed? The first perspective certainly complicates things.
-
2Most people go with approach 2 (commands/queries in application layer) because it's way simpler. The "commands as domain messages" thing sounds nice theoretically but usually just adds unnecessary layers. Why make your controllers go through another service when they could dispatch commands directly? Stick with the application layer approach - your CreateOrderCommand is about "what can this app do". keep it practicalLewie– Lewie2025-08-19 13:03:48 +00:00Commented Aug 19 at 13:03
-
DDD and its patterns fit more naturally with the command side of CQRS, not so well with the query side.David Osborne– David Osborne2025-08-21 13:01:04 +00:00Commented Aug 21 at 13:01
Add a comment
|