DTO or Domain Model Object in the View Layer?

前端 未结 9 1981
再見小時候
再見小時候 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:25

    The behavior of a class, or its internal methods should not be exposed to layers not concerned with their behaviour. Transfer data, not behaviour. Use domain objects within the domain. The web is not a controlled domain, and UI developers need not be concerned with domain behaviour, just data.

    The domain has to be encapsulated, and protected from modification by someone not concerned with the health of the domain.

    Leaking behaviour is not the best habit.

    If it is a small project, built it with correct principes as well. That way we always keep in mind why we do what we do, and not just how.

提交回复
热议问题