Pascal casing or Camel Casing for C# code?

后端 未结 14 1037
终归单人心
终归单人心 2020-12-05 17:17

I\'ve been arguing with my coworkers about Pascal casing (upper camel case) vs. lower CamelCasing. They are used to lower camel casing for everything from table names in SQL

14条回答
  •  执念已碎
    2020-12-05 18:14

    You should have a look at Microsoft's new tool, StyleCop for checking C# source code. Also keep an eye on FxCop for checking compiled .Net assemblies. FxCop focuses more on the details of what the code does, not the layout, but it does have some naming rules related to publicly visible names.

    StyleCop defines a coding standard, which is now being promoted by Microsoft as an industry standard. It checks C# source code against the standard. StyleCop adheres to your PascalCase style.

    Getting people onto StyleCop (or any other standard for that matter) can be hard, it's quite a hurdle, and StyleCop is quite exhaustive. But code should be to a uniform standard - and a personal standard is better than none, company standard is better than a personal one, and an industry standard is best of all.

    It's a lot easier to convince people when a a project starts - team is being formed and there is no existing code to convert. And you can put tools (FxCop, StyleCop) in place to break the build if the code does not meet standards.

    You should use the standard for the language and framework - SQL code should use SQL standards, and C# code should use C# standards.

提交回复
热议问题