从DAL返回的对象的DTO等价术语是什么? [英] What is DTO equivalent term for objects returned from DAL?

查看:129
本文介绍了从DAL返回的对象的DTO等价术语是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在使用DTO通过网络进行数据传输了。现在,我还将DAL引入不同的DTO类。这是为了避免跨层传递应用程序(业务)对象。

I'm already using DTO's for data transfer over a network. Now I'm also introducing different DTO-like classes to the DAL. This is to avoid passing the application (business) objects across layers.

为避免命名混乱,我想使用DTO以外的其他术语,但找不到合适的术语。一个。

To avoid naming confusion, I would like to use another term than DTO but can't find a good one.

从DAL返回的对象的DTO等效项是什么?

What is DTO equivalent term for objects returned from DAL?

推荐答案


名字叫什么?我们以其他名字称呼玫瑰会闻起来很香。 -威廉·莎士比亚(William Shakespeare)

"What's in a name? that which we call a rose by any other name would smell as sweet." - William Shakespeare

此外,马丁·福勒(Martin Fowler)关于POJO的说法

Also, what Martin Fowler says about POJO:


在谈话中,我们指出了将业务逻辑编码为常规的Java对象,而不是使用实体Bean。我们想知道为什么人们不反对在他们的系统中使用常规对象,并得出结论,这是因为简单对象缺少奇特的名称。所以我们给了他们一个,而且非常流行。

顺便说一句,这没关系。为了避免由于类似的命名而引起的混乱,您可以从 DataModel, Entity, POCO中进行选择。

By the way, it does not matter that much. Looking at your concern to avoid confusion due to similar naming, you may choose from "DataModel", "Entity", "POCO".

以下内容非常宽松 注意事项用于通常使用的不同术语:

Following are very loose considerations for different terms generally used:

关系模型[数据库层]:


  • 数据库,表和字段。

持久性模型[数据访问层]:


  • (通常)属于ORM或与数据库紧密映射的模型。 / li>
  • 这用于持久性需求。

域模型/业务模型[业务逻辑/服务层]:


  • 公开给BLL /服务层的模型。

查看模型[UI层]:


  • 暴露给View的模型。

DTO:


  • 仅按住y状态,用于将数据从一层传输到另一层。

  • 除序列化外没有任何行为/逻辑。

  • 最好可序列化。 li>
  • 针对请求层设计;与数据库不相似。

  • 没有自己的身份。

  • Holds only state and used to transfer data from one layer to other.
  • Does not have any behaviour/logic except serialization.
  • Preferably serializable.
  • Designed against requesting layer; does not resemble with database.
  • Does NOT have its own identity.

POCO:


  • 它只是一个常规对象,没有对任何特定框架的引用,也不遵循其接口或限制

  • 可以与任何ORM一起使用的持久性忽略对象。

  • 保留数据库中的数据。

  • 不一定可序列化。

  • 针对数据库请求而设计。

  • 可能具有验证逻辑或与POCO紧密绑定的逻辑(例如数据加密/唯一性)

  • 没有诸如Get,Save等之类的持久性方法。POCO无法填充自身。

  • MAY具有其自己的身份。 / li>
  • It is simply a regular object that has no references to any specific framework and does not follow their interfaces or restrictions.
  • Persistence ignorant objects that can be used with any ORM.
  • Holds data from database.
  • Not necessarily serializable.
  • Designed against database request.
  • May have logic for validation or other that is tightly bound to POCO (like data encryption/uniqueness of column).
  • Does NOT have persistence methods like Get, Save etc. POCO does not fill itself.
  • MAY have its own identity.

实体:


  • 它必须具有自己的身份并且可以唯一标识。

  • 可以使用DataContext从数据库中加载并保存到数据库的对象。

  • 没有它的DataBaseContext就不能存在。

  • 与特定的ORM紧密绑定并实现其规则(默认构造函数,用于创建运行时代理的虚拟属性等)。

  • 实体代表域模型和域逻辑。

  • It MUST have its own identity and can be uniquely identified.
  • Object that can be loaded from and saved to a database using a DataContext.
  • Cannot exist without its DataBaseContext.
  • Tightly bound with specific ORM and implements its rules (default constructor, virutal properties to create runtime proxies etc.).
  • Entities represent domain model and domain logic.

模型:


  • 常用术语,用于表示任何保存数据的对象。

  • 以上所有对象,

请参考以下答案:

https://stackoverflow.com/a/37751345/5779732

https://stackoverflow.com/a/42801839/5779732

这篇关于从DAL返回的对象的DTO等价术语是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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