在三层架构中使用DTO [英] Use of DTO in 3 tier architecture

查看:311
本文介绍了在三层架构中使用DTO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用简单的3层体系结构。
在此,我使用DTO类在UI,BL和DL之间进行通信。
那么,层之间还有更好的通信方式吗?还是这是正确的方法?

I am using simple 3 tier architecture. In this I am using DTO classes to communicate between UI,BL and DL. So there is any better way for communication between layers? or this is the right way?

推荐答案

DTO,数据传输对象,是分布层的概念,在传输数据时使用在您的消费者和您的服务之间。因此,如果您不发布任何服务,请下DTO。

DTO, Data transfer Object, is the concept for distribution layer, you use when transferring data between your consumers and your service. So, if you don't publish any service, get off DTO.

要回答您的问题,还取决于您的应用程序有多复杂。如果简单,则只需使用CRUD操作,甚至可以使用 DataTable DataSet 进行通信。

To answer your question, it also depends on how complex your application is. If it's simple, just use CRUD operation, or you can even use DataTable, DataSet for communication.

否则,DDD中的域实体是各层之间的通信的核心对象:数据访问层,业务逻辑层和表示层。

Otherwise, Domain Entity from DDD is the core object for communication between layers: Data Access Layer, Business Logic Layer and Presentation Layer.

基本上,应用程序中有一些不同类型的对象:

Basically, there are some different type of objects in application:


  1. DTO,在您进行公共服务时使用,主要对象用于消费者之间的通信

  2. 视图模型,表示层中的对象用于支持UI。

  3. 域实体来自业务逻辑层,其中包含业务逻辑。 / li>
  1. DTO, use when you public services, main object to communicate between consumer and your service.
  2. View Model, object in presentation layer to support UI.
  3. Domain Entity is from Business logic layer to contain business logic.

请注意以下术语:


  1. :表示物理层,例如数据库服务器,Web服务器。

  2. :表示逻辑层:表示层,业务逻辑层,数据访问层。

  1. Tier: it means physical, like database server, web server.
  2. Layer: it means logical layer: Persentation Layer, Business Logic Layer, Data Access Layer.

这篇关于在三层架构中使用DTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆