开发者

Passing list of exceptions Back to Caller - Domain Driven Design

开发者 https://www.devze.com 2022-12-16 04:34 出处:网络
I am new to DDD but I am trying to implement it in my Project - I have a service which is setup following the DDD principles - Application / Model / Repository - The Clients of the Service want to get

I am new to DDD but I am trying to implement it in my Project - I have a service which is setup following the DDD principles - Application / Model / Repository - The Clients of the Service want to get back a DTO class (which also contains a Error Collection as one of its members) . Ques开发者_如何学JAVAtions is how do I populate the Error Collection of the result DTO. Can the Error DTO be passed from the Application/Service Layer to Model/Service layer and populated there – Can someone point me to some example of these kinds of scenarios Currently I am bubbling up all the errors that I am getting back to the Application Service and populating it there like I said I am struggling.


As a general rule try not to copy code (classes, methods, interfaces). If you really have to use DTOs create them as late as possible in the process so that if you remove them you should still be able to use the system in another way.

I would have something like this: Model

  • Domain classes
  • Error class

Model/Service (has reference to Model)

Application/Service (has reference to Model and Model/Service)

  • Domain DTOs
  • Error DTO

Also a question do you really need two Service Layers? Avoid Anemic Domain Model

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号