ASP.NET MVC视图模型命名约定 [英] ASP.NET MVC View Model Naming Conventions
问题描述
我知道我对此可能会有不同的看法,但是我想知道是否存在关于模型命名约定的最佳实践".
I know I will probably get a mixed opinion on this, but I was wondering if there were and "Best Practices" for model naming conventions.
我有一个相当大的应用程序,并且采用了以下模型命名约定:
I have a rather large application and I have adopted the following model naming convention:
- 型号
- 添加
- CategoryAddModel
- ProductAddModel
- Models
- Add
- CategoryAddModel
- ProductAddModel
- CategoryEditModel
- ProductEditModel
- CategoryViewModel
- ProductViewModel
我也在考虑以下内容:
- 型号
- 添加
- AddCategoryModel
- AddProductModel
- Models
- Add
- AddCategoryModel
- AddProductModel
- EditCategoryModel
- EditProductModel
- ViewCategoryModel
- ViewProductModel
您更喜欢哪个,为什么?
Which do you prefer, and why?
您认为这真的很重要吗?
Do you think it really matters?
推荐答案
没关系.您应该以一致,逻辑和直接的方式命名事物.基本上,只选择有意义的东西并使您的工作效率最高.考虑您的命名约定如何与IntelliSense配合使用.
It doesn't matter. You should name things in a consistent, logical, and straightforward way. Basically, just pick something that makes sense and makes you most productive. Consider how your naming convention would work with IntelliSense.
您可能还想考虑一下,从现在开始一年后维护代码的难易程度.
You might also want to consider how easy your code will be to maintain a year from now.
这篇关于ASP.NET MVC视图模型命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Add
- 添加
- Add
- 添加