Difference between Transfer objects and Domain objects

前端 未结 4 418
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 08:41

Could you please explain the difference between Transfer objects and Domain objects in simple terms ? And if u could give a Java example, that would be great..

4条回答
  •  悲哀的现实
    2021-01-30 09:32

    • DTOs don't have any logic. They only have fields (state). They are used when transferring data from one layer/subsystem to another
    • Domain objects can have logic (depending on whether you are using domain-driven design or have anemic data model) and they are usually related to the database structure.

    If using anemic data model (i.e. your domain objects don't have any logic), DTO and domain object can be the same object.

    Related: http://techblog.bozho.net/?p=427

提交回复
热议问题