ASP.NET MVC 视图模型命名约定 [英] ASP.NET MVC View Model Naming Conventions

查看:32
本文介绍了ASP.NET MVC 视图模型命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道对此我可能会有不同的看法,但我想知道模型命名约定是否存在最佳实践".

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:

  • 模型
    • 添加
      • 类别添加模型
      • ProductAddModel
      • 类别编辑模型
      • ProductEditModel
      • 类别视图模型
      • ProductViewModel

      我也在考虑以下问题:

      • 模型
        • 添加
          • 添加类别模型
          • 添加产品模型
          • 编辑类别模型
          • 编辑产品模型
          • ViewCategoryModel
          • 查看产品模型

          你更喜欢哪个,为什么?

          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屋!

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