本文介绍了DDD"查看对象"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于涉及到,比如说公司,我可能有一个公司类的应用程序。我将有一个填充列表℃的数据访问层;公司取代。但是,会有时间(如显示搜索结果),我只需要显示公司名称,电话及邮政编码属性,这在我看来,以填充其所有属性,整个公司似乎对象的浪费。

Given an application that involves, say, Companies, I might have a Company class. I will have a data access layer that populates a List <Company>. However, there will be times (such as displaying a search result) where I only need to display the Company name, telephone and postcode properties, and it seems to me that populating the entire Company object with all its properties seems wasteful.

什么是去了解这个在DDD设计方面的正确方法?我会创造查看特定的类,如CompanySearchResult对象,该对象仅公开我感兴趣的显示属性?

What would be the right way to go about this in terms of a DDD design? Would I create View specific classes, such as a CompanySearchResult object which only exposes the properties I'm interested in displaying?

推荐答案

这听起来像一个合理的办法给我。

That sounds like a reasonable approach to me.

后来,如果客户来给你要求你的信息搜索结果来显示一些无关的公司模式 - 东西发疯似的附近的冰淇淋店的数量你就会有一个更容易地附加给你的 CompanySearchResult 比你的域对象。

Later on, if the customer comes to you asking for your SearchResult to display something unrelated to the Company model - something crazy like the number of nearby ice cream shops you'll have a much easier time appending this to your CompanySearchResult than your domain object.

这篇关于DDD&QUOT;查看对象&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:35