DTO、DAO 和 DCO。 什么是 DCO?

发布于 2024-07-17 09:44:29 字数 134 浏览 8 评论 0原文

我对DCO含义的搜索很无果,所以我决定在这里问一下。 在我的Java应用程序中,有很多类,例如EmployeeDetailsDto、EmployeeDetailsDao,但最近我还遇到了EmployeeDetailsDco。 有谁知道DCO代表什么?

My search for the meaning of DCO was quite fruitless, so I decided to ask here. In my Java application, there are many classes like EmployeeDetailsDto, EmployeeDetailsDao, but recently I also came across EmployeeDetailsDco. Does anyone know what does the DCO stand for?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

妖妓 2024-07-24 09:44:29

DTO = 数据传输对象

DAO = 数据访问对象

DCO =
动态可配置对象

来自 文章

动态可配置对象 (DCO)

其实现在运行后可以增量更改的对象,

  • 由接口元素
  • public function
  • private function
  • private data 以及所有访问器函数
  • 增量更改
  • 成员函数支持对界面元素添加、删除或更改的

DTO = Data Transfer Object

DAO = Data Access Object

DCO =
Dynamically Configurable Object?

From the article

Dynamically configurable object (DCO)

an object whose implementation can change incrementally after it is running

  • consists of interface elements
  • public function
  • private function
  • private data along with all accessor functions
  • member functions support incremental changes to interface elements
  • adding, removing, or altering
清风挽心 2024-07-24 09:44:29

我刚刚和一个曾经记得这代表什么的人交谈过。 具有讽刺意味的是,他不再这样做了。 这家公司的其他人也没有。

我能找到的解释是,它基本上是一个 DTO,但他们想使用 DCO 来区分 Hibernate 使用的 DTO 和外部系统(在本例中为 LDAP)使用的 DCO。

因此,我相信 DCO 的含义实际上可能是,正如 Bhushan 所说的那样,数据承载对象或类似的东西,在这种情况下,它确实只是 DTO 的另一个名称。 答案已接受。 谢谢你的时间! 我以为 DCO 是开发人员广泛使用的公认缩写词,但事实证明只是这样......抱歉。

对于那些感兴趣的人来说, 编辑


答案是数据容器对象。 我在公司引起了足够的轰动,所以最终一位同事给 DCO 术语的本地创始人发了电子邮件,如果有人仍然想知道的话,它代表数据容器对象

I just spoke to the guy who used to remember what this stands for. It's pretty ironic that he no longer does. Nor do any other people here in this company.

The explanation I could find was, that it's basically a DTO, but they wanted to use DCO to differentiate between DTOs used by Hibernate and DCOs used by external systems, in this case LDAP.

So I believe the meaning of DCO could really be, as Bhushan suggests, Data Carrying object or the like, and in this case it was indeed intended to be just another name for DTO. Answer accepted. Thanks for your time! I thought DCO was an accepted acronym widely used by developers but it turned out to be just this... sorry.

Edit


THE answer is Data Container Object, for those interested. I have caused enough stir in the company so eventually a colleague emailed the local originator of the DCO term and, if anyone still cares to find out, it stands for Data Container Object.

漆黑的白昼 2024-07-24 09:44:29

我只能说Data Carrying Object不是DCO的意思,在google中输入“Data Carrying Object”,它不会返回任何命中。

因此,这些条款一定是错误的。

好吧,尝试用谷歌搜索“Data Objects DCO”

并得到这个 结果,这表明DCO 的意思是“数据更改对象”

我的猜测是 DCO 是一个保存对象数据更改(即“差异”)的对象。

All I can say is Data Carrying Object is not what DCO means, put "Data Carrying Object" in google and it doesn't return any hits.

Thus the terms has to be wrong.

Ok tried googling "Data Objects DCO"

and got this result, which would suggest DCO means "Data Change Objects"

My guess is a DCO is an object that holds changes, a "diff", of the Object's Data.

小梨窩很甜 2024-07-24 09:44:29

我从未听说过 DCO,但它只是 DTO 的另一个名称吗?

I have never heard of DCO but is it Data Carrying Object just another name for DTO?

我偏爱纯白色 2024-07-24 09:44:29

重构 Dtos 并删除 DTO 后缀。

您可能想将 Dao 更改为 Store 或类似的东西。

首先,末尾没有 Dto/dco 的 EmployeeSetails 显然是一个保存与员工相关的值的值类。 如果没有其他术语,很明显它不是一个实用程序 - 应该将其称为 EmployeeDetailsUtil/Helper 等。

您的 dao 应该称为 EmployeeSetailsS​​tore,因为它描述了它的功能,即 EmployeeSetsils 的存储。 如何或将它们放置在何处无关紧要,它们隐藏在您的代码中。 如果你真的想要的话,如果它使用 Hibernate,你可以将其称为 HibernateEmploteeDetaileStore 等。 您的界面应称为 EmployeeSetailsS​​tore。 实现者或此接口将使用接口名称作为开始,并将 impl 技术添加到该基本名称中。

最后但并非最不重要的一点是,这里 String 是 char 数组的值,但在这种情况下添加 Dto 是丑陋且愚蠢的。

仅应使用众所周知的首字母缩略词,例如 Url。 最后,商店永远不会令人困惑,而您提到的所有首字母缩略词并没有让事情变得更清楚,在这种情况下引入了共融合和这种涂层时间。

如果您使用我建议的方法来测量打字,您实际上会输入更少的字符,并且一切都会更清晰。 总是以清晰而不是简洁为目标,毕竟我们都是快速打字者,所以还有一些额外的字符吗? 最后,我们花更多的时间阅读、理解等而不是打字,所以类名中的一些额外字符根本不会降低生产力……

不要吝啬……从一开始就正确执行。

Refactor the Dtos and drop the DTO suffix.

You might want to change Dao to Store or something similar.

Firstly EmployeeSetails without Dto/dco on the end obviously is a value class holding values relating to an employee. Without another term it's obvious it's not a utility - which should be called something g like EmployeeDetailsUtil/Helper etc.

Your dao should be called EmployeeSetailsStore because that describes it's function a store of EmployeeSetsils. How or where it puts them is irrelevant they are hidden away in your code. If you really wanted to you could call it HibernateEmploteeDetaileStore etc if it used Hibernate. Your interface should be called EmployeeSetailsStore. Implementors or this interface would use the interface name as a start and add impl technology to that base name.

Last but not least String is a value here of a char array but adding Dto in this case is ugly and silly.

Only really well known acronyms like Url should ever be used. In the end Store can never be confusing while all the acronyms you mentioned don't make things clearer and in this case introduced co fusion and this coated time.

If you measure the typing using what I have suggested you actually type less characters and everything is clearer. always aim for clarity rather than terseness after all we are all fast typers so what's a few extra chars. In the end we spend more time Reading, understanding etc than typing so a few extra chars in a class name isn't going to reduce productivity at all ...

Don't skimp...do it properly from the beginning.

半世晨晓 2024-07-24 09:44:29

这可能是命令对象。

This might be Command Object.

温柔戏命师 2024-07-24 09:44:29

我使用DCO作为数据转换对象。

例如,您有:

  1. 用于通过网络传输用户的 dto.User(例如,使用 Jackson 注释并映射到 JSON 接口)和:
  2. 用于存储的 dao.User数据库中的用户(例如,使用 JPA 注释并映射到具有与 JSON 传输对象不同的字段和格式的旧数据库)

您需要在两者之间进行转换。

不要将转换逻辑写入不属于它们的 DTO 或 DAO 中,而是将它们放在 DCO 中。

这样您就有了 dco.User:

package com.mycompany.myapp.dco;

// converts between data access objects (DAOs) and data transfer objects (DTOs).
public class User {
    com.mycompany.myapp.dao.User toDao(com.mycompany.myapp.dto.User) {
        // dto to dao conversion.
    }

    // could call this method fromDao if that is preferred.
    com.mycompany.myapp.dto.User toDto(com.mycompany.myapp.dao.User) {
        // dao to dto conversion.
    }
}   

然后您可以轻松实现和测试转换,并在整个服务层中任何需要的地方调用它们。

这种模式的另一种用法可能是在 模型视图中当您需要在模型和视图模型之间进行转换时,可以使用 UI 的视图模型 MVVM 架构。 在这种情况下,视图模型绑定了视图,并且可以由用户在 UI 中直接操作进行更改,但模型保持独立,例如当您想要将更改加载或保存到磁盘时。 在这种情况下,提供数据转换对象(我称之为 DCO)可以帮助在相似事物的两种不同表示之间来回转换。

请注意,根据这种理解,DCO 实际上只是一组函数而不是一个有状态对象。 因此,您可以将其称为 DataConvertor,或者如果您愿意,您可以将所有转换函数放在一个工厂类中,用于所有需要转换的对象的整个域层。

这只是我有时做的事情,并不一定是标准。 其他人可能会使用 DCO 来代表其他事物。

I use DCO as a data conversion object.

For example, you have:

  1. A dto.User for transferring users across the network (e.g. annotated with Jackson and mapping to a JSON interface) and:
  2. A dao.User for storing users in a database (e.g. annotated with JPA and mapping to a legacy database with different fields and formats from the JSON transfer object)

You need to convert between the two.

Rather than writing that conversion logic in the DTO or DAO where they don't belong, put them in a DCO.

So you have dco.User:

package com.mycompany.myapp.dco;

// converts between data access objects (DAOs) and data transfer objects (DTOs).
public class User {
    com.mycompany.myapp.dao.User toDao(com.mycompany.myapp.dto.User) {
        // dto to dao conversion.
    }

    // could call this method fromDao if that is preferred.
    com.mycompany.myapp.dto.User toDto(com.mycompany.myapp.dao.User) {
        // dao to dto conversion.
    }
}   

Then you can easily implement and test the conversions and invoke them wherever they are needed throughout the service layer.

Another usage for such a pattern might be in a model view view-model MVVM architecture for UIs when you need to translate between the model and the view-model. In such a case the view-model is bound the view and can be changed be directly manipulated by the user in the UI, but the model is kept separate, e.g. when you want to load or save changes to disk. In such cases providing a data conversion object, or DCO as I call it, can assist in the translations back and forth between the two distinct representations of the similar thing.

Note, under this understanding, the DCO is really just a set of functions rather than a stateful object. So you could just call it a DataConvertor or you you could put all of the conversion functions in a single factory class for your whole domain layer of all objects which need conversion if you preferred.

This is just something I sometimes do, and not necessarily a standard. Some other person may use DCO to stand for something else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文