DTO 中的枚举类型命名约定

发布于 2024-12-05 18:43:08 字数 269 浏览 2 评论 0原文

我正在域模型前面创建一个应用程序外观,并使用 dto 进行消费者和外观之间的交换。

为了避免必须完全限定在 dto 和域模型之间映射的命名空间,我在所有 dto 后面加上了 Dto 后缀。 IE。 CustomerDto、AddressDto 等。

我还需要定义一个枚举类型作为我的 dto 的一部分,并且正在努力考虑是否应该在我的枚举类型上使用 Dto 后缀。

我很好奇其他人对驻留在他们的 dto 中的枚举类型做了什么。如有任何反馈,我们将不胜感激。

谢谢

I'm creating an application facade in front of my domain model and using dto's for the exchanges between the consumer and the facade.

In order to avoid having to fully qualify my namespaces where I'm mapping between dto's and the domain model, I've suffixed all my dto's with Dto. Ie. CustomerDto, AddressDto etc.

I need to define an enum type as part of my dto's as well and am struggling with whether I should use the Dto suffix on my enum type.

I'm curious what others have done with enum types that reside in their dto's. Any feedback is appreciated.

Thank You

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

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

发布评论

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

评论(3

本宫微胖 2024-12-12 18:43:08

假设您在说“枚举”时谈论的是 enum 类型,我不会在它后面加上 Dto 后缀,因为事实并非如此。例如,我不会说 CustomerTypeDto 因为它不是代表客户类型的 DTO。但是,它是一个表示 CustomerDto 类型的 enum,因此也许 CustomerDtoType 比较合适。

Assuming you're talking about an enum type when you say "enumeration," I wouldn't suffix it with Dto, since that's not really what it is. For example, I wouldn't say CustomerTypeDto since it's not a DTO representing a customer type. However, it is an enum representing the type for a CustomerDto, so maybe CustomerDtoType would be appropriate.

我很坚强 2024-12-12 18:43:08

就我个人而言,我只会使用单独的命名空间和相同的名称作为枚举类型。我认为将两者分开很重要,以便外部的只是模型的用例投影。

Personally I would just use a seperate namepspace and the same name for the enumeration type. I think it's important keep the two seperate so that the external one is just a use case projection of the model.

往日 2024-12-12 18:43:08

如果您使用“Dto”后缀作为域模型代理,则可以应用相同的逻辑并使用“Enum”作为枚举。

例如,您将有一个“CustomerDto”和“CustomerTypeEnum”。

这是我在当前项目中遇到的一个问题,这就是我将要使用的解决方案。

If you use the 'Dto' suffix for your domain model proxies, you could apply the same logic and use 'Enum' for your enums.

So for instance you'd have a 'CustomerDto' and 'CustomerTypeEnum'.

That's a question I just had in my current project and that's the solution I'm going to use.

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