Plain Old CLR Object vs Data Transfer Object

后端 未结 10 1610
挽巷
挽巷 2020-11-22 13:38

POCO = Plain Old CLR (or better: Class) Object

DTO = Data Transfer Object

In this post there is a difference, but frankly most of the blogs I read describe P

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 14:15

    POCO is simply an object that does not take a dependency on an external framework. It is PLAIN.

    Whether a POCO has behaviour or not it's immaterial.

    A DTO may be POCO as may a domain object (which would typically be rich in behaviour).

    Typically DTOs are more likely to take dependencies on external frameworks (eg. attributes) for serialisation purposes as typically they exit at the boundary of a system.

    In typical Onion style architectures (often used within a broadly DDD approach) the domain layer is placed at the centre and so its objects should not, at this point, have dependencies outside of that layer.

提交回复
热议问题