多层应用程序中的模型命名约定 [英] Naming conventions for model in multi layer application

查看:70
本文介绍了多层应用程序中的模型命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是我从未在大型企业工作过的新开发人员,所以我对多层应用程序中的命名约定有疑问.我有一个带有EF数据层的WPF/MVVM应用程序.我也想调整DDD原则.

I'm a new developer I have never worked in big enterprise company so I have a question about naming conventions in multi-layer application. I have a WPF/MVVM application, with EF data layer. I also want to adjust DDD principles.

所以,我会说三个相同类别的模型.我在MVVM中有模型",在EF中有一个实体/dto(我不知道吗?),在DDD中有域模型/POCO.我必须创建所有这三个类来分开关注点(也许我可以将MVVM模型与POCO合并.我的意思是,POCO是MVVM中的一种模型).我该怎么命名?

So, I three models of the same class I would say. I have "model" in MVVM, I have a entity/dto(I don't know?) in EF, I have domain model/POCO in DDD. I have to create all those 3 classes to separate concerns (maybe I could merge MVVM model with POCO. I mean, POCO is kinda model in MVVM). How should I name them?

假设我有POCO人.在EF中应该是"Person"还是"PersonDto"?一般惯例是什么?我遇到过两种都带有Dto后缀的方法,所以我很困惑.

Let's say I have Person POCO. Should it be "Person" or "PersonDto" in EF? What's the general convention? I've met both ways w/wo Dto postfix, so I'm confused.

推荐答案

我通常在DTO和ReadModels/ViewModels后缀,但不添加域对象.

I usually suffix the DTOs and ReadModels/ViewModels, but not the domain objects.

没有硬性规定,这是个人(或团队)偏好的问题.有些人喜欢让名称空间代替它,但是我发现它不太明确.

There's no hard and fast rule, it's a matter of personal (or team) preference. Some like to let namespaces do the trick instead, but I find it less explicit.

编辑:顺便说一句,我是(而我不是唯一的).在任何情况下,我都不会在 DTO 层中调用对象.

Edit : btw, I'm not a huge fan of having a separate "persistence model" (and I'm not the only one). And in any case, I wouldn't call objects in that layer DTO's.

这篇关于多层应用程序中的模型命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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