Replies: 5 comments 3 replies
-
When you think about it, it's better to have separate logic for every Command/Query, since when you change you are going to touch one use case at a time, unless you modify the domain layer. However, sometimes, you find yourself doing the same thing in different places, ask yourself if it's really an Application layer logic (maybe it should be in the domain layer as a method of a rich entity). And AFAIK, there is no restriction rule about creating other classes that you can use in your application layer to abstract common logic. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I let you read this good explanation why we use rich entities : https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/microservice-domain-model#rich-domain-model-versus-anemic-domain-model In a nutshell, using anaemic entities is a procedural pattern and can easily lead to spaghetti code. However, in simple Crud applications you don't really need them you might even not need Clean Architecture for that. |
Beta Was this translation helpful? Give feedback.
-
Not trolling, I am just trying to figure out where I put business logic that needs to be reused in my commands. |
Beta Was this translation helpful? Give feedback.
-
If they are invariants to the order which is an aggregate root - its fine. If not you create a domain service to enable you to interact with two aggregate roots at the same time whilst still maintaining your fundamental concepts. Choosing aggregate roots and invariants is not always easy but is done not on references between two objects, but enterprise logic between the two that must be kept consistent such as validation As in my other reply, domain shouldnt have infrastructure I think again you are misunderstanding clean architecture. It has layers and the UI/API layer is fundamentally different to the domain layer and has different reasons for changing. You should map your domain object to a data transfer object, restful resource, etc. |
Beta Was this translation helpful? Give feedback.
-
Does anyone else seem like a service layer is missing in application when your trying not to repeat yourself (DRY)?
I have typically put my logic in the commands until I need to reuse them in other areas. I then move them to a service class.
Was wondering how other people are handling this, I cant be the only one.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions