0

In a DDD-CQRS scenario, should my commands in the Application/Service layer always be just a facade to different aggregation method and other inner layers like repository calls in the infrastructure layer? Or should commands retain business logic inside it (consequently transferring that logic from domain models to the commands in a non-CQRS environment)?

4
  • Thought work. If you are planning to borrow logic from the domain and place it somewhere else. Why bothering on implementing DDD in the first place?
    – Laiv
    Jul 31, 2021 at 10:39
  • @Laiv I'm not planning on that. I'm trying to understand the proper way to implement CQRS. From my understanding of DDD, commands should be just a simple facade. However this is not what I see in most projects I read, that's why I decided to ask here. Jul 31, 2021 at 13:14
  • 1
    You might find interesting Greg Young CQRS files. It's likely other opinions on internet will be biased by Greg's understading of CQRS. You know, it's easier to leave other do the hard job of thinking. Following is easier. But be carefuly and read everything with a critical thinking because CQRS is just a tool that you can use and adapt in the way that best serves you. So try to don't look for the Saint Grail, be pragmatic
    – Laiv
    Jul 31, 2021 at 19:40
  • @Laiv I'll take a look, thanks for shedding some light on this. If you want to submit an answer, I'll accept it. Jul 31, 2021 at 21:08

1 Answer 1

1

CQRS is a rebranding of CQS is a rebranding of DDDD - "Distributed Domain Driven Design". For the most part, the guidelines of Domain Driven Design hold.

In particular: your "domain layer" is distinct from your "application layer"; all of the complexity of the domain itself belongs in the domain layer, the work of delivering information to the domain layer or extracting information from the domain layer lives in the application.

The method through which the Application Server will be told what to do is through the use of a Command. -- Greg Young, 2010.

Just to add to the confusion, there are two different but overlapping understandings of "Command", both of which are used in CQRS. We have Command in the Bertrand Meyer sense (see Fowler, 2005), and also Command in the Gregor Hohpe sense (Hohpe, 2003). In one case we are talking about the semantics of methods on an object, in the other we are talking about the semantics of messages.

We send a command "message" with information across a network to a system so that we can share information with an object via a command (not effectively read only) method.

The usual answer in DDD:

Concentrate all code related to the domain model in one layer and isolate it from the user interface, application, and infrastructure code.

So you'll normally expect to find the "business logic" within the domain layer, not out in the application layer which is a more common home for the "command" pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.