首页新闻找找看学习计划

什么是DTO,有没有比较简单的示例代码或通俗的讲解

1
悬赏园豆:50 [已解决问题] 解决于 2011-11-25 10:59

请问什么是DTO,有没有比较简单的示例代码或通俗的讲解?

dto
artwl的主页 artwl | 专家六级 | 园豆:16526
提问于:2011-11-24 22:10
< >
分享
最佳答案
1

小弟登录专门为回答大侠问题

Data Transfer Object
When you're working with a remote interface, such as Remote Facade , each call to it is expensive. As a result you need to reduce the number of calls, and that means that you need to transfer more data with each call. One way to do this is to use lots of parameters. However, this is often awkward to program - indeed, it's often impossible with languages such as Java&CSharp that return only a single value.

The solution is to create a Data Transfer Object that can hold all the data for the call. It needs to be serializable to go across the connection. Usually an assembler is used on the server side to transfer data between the DTO and any domain objects.

 

详细资料可以参考下边:
http://en.wikipedia.org/wiki/Data_transfer_object
http://msdn.microsoft.com/en-us/library/ms978717.aspx
http://martinfowler.com/eaaCatalog/dataTransferObject.html 

收获园豆:30
麦田里的守望者 | 菜鸟二级 |园豆:428 | 2011-11-25 00:16

以前对DTO有所了解,只知道不包含逻辑代码,只是对下面的类型是不是DTO类型存有疑惑:

public class UserInfo
{
public int UserID { get; set; }
public string UserName { get; set; }
public Collection<Friend> Friends { get; set; }
}



artwl | 园豆:16526 (专家六级) | 2011-11-25 09:39

@artwl: 

我觉得是,你觉得呢,向@dudu老大求救啊

麦田里的守望者 | 园豆:428 (菜鸟二级) | 2011-11-25 09:58

@麦田里的守望者: 

我也觉得是

artwl | 园豆:16526 (专家六级) | 2011-11-25 10:47
其他回答(1)
0

看看 Martin Fowler的 企业应用架构模式

收获园豆:20
ChatinCode | 园豆:2272 (老鸟四级) | 2011-11-25 10:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册