DDD “View Objects”?

后端 未结 4 718
情歌与酒
情歌与酒 2021-02-14 18:01

Given an application that involves, say, Companies, I might have a Company class. I will have a data access layer that populates a List . However, there will be

4条回答
  •  佛祖请我去吃肉
    2021-02-14 18:22

    This is what is typically known as a "view model" or a Data Transfer Object. You may not want your view to have access to the entire data tree exposed by your domain model. Especially if exposing your domain model means that your view will have to dig deep into your object graph to pull the data it needs, a View Model can make alot of sense to simplify working with the model objects. In your case, if you are simply pulling direct properties off of the model object, it would make sense if you want to hide the extraneous data not needed by the rest of your domain model.

提交回复
热议问题