kgrzybek / sample-dotnet-core-cqrs-api

Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
https://www.kamilgrzybek.com/design/simple-cqrs-implementation-with-raw-sql-and-ddd/
MIT License
2.86k stars 641 forks source link

Query Handlers and responsabilities #10

Closed Lobosque closed 4 years ago

Lobosque commented 4 years ago

Hi, congratulations for the effort putting this up.

I have one question regarding the query handlers. Why are they in Application? Doesn't that mean that you are coupling your Infrastructure with business logic? Just want to understand what weighted your decision and what you would suggest for a more strict decoupling.

dmoka commented 4 years ago

I am not the owner of the repo, but I try to give me point of view on it. In DDD, in the application layer the business use cases are orchestrated. The queries and the corresponding handlers reflects the actual business use cases, therefore the Application layer is a good place for them. Note, that in this layer there is not much business logic happening, and all of them are delegated mostly to the Domain entities which are part of the Domain layer.

I hope it helps, though let's see what the owner's opinion is about it.

kgrzybek commented 4 years ago

Hi @Lobosque I agree totally with @mirind4, thanks for that answer!

What I can add:

Lobosque commented 4 years ago

@mirind4 @kgrzybek thank you for your replies! I am closing the issue as they answer my initial question/request.