DTO or Domain Model Object in the View Layer?

前端 未结 9 1950
再見小時候
再見小時候 2020-12-22 17:32

I know this is probably an age-old question, but what is the better practice? Using a domain model object throughout all layers of your application, and even binding values

9条回答
  •  醉梦人生
    2020-12-22 18:27

    I think what we should consider here in the first place is the cost of introducing new layer. Take DTO for instance - doing that we need a mapping. As someone said, translation is evil and should be avoided whenever possible.

    On the other hand I think there are very few things that you generally should not do. Those who say all DTOs are evil are wrong - it always depends on the use case! Are they really justified?

    And finally, I personally believe the domain objects should be let go to the view itself. Imagine what the wicket integration is then like. But take Spring MVC for instance - domain would stay then in the application layer probably...

提交回复
热议问题