Arne Brachhold

.Net Coding Guidelines

Filed under: .Net — arne on May 23, 2005

If you code in a team, it is important that you use the same code style, especially if developers began with different languages which had individual styles. For example, PHP is often coded with camelCase and C++ developers use prefixes like strName or intZipCode.

Modern IDEs allow you to see the type of your members or variables while working with them. Visual Studio shows the type in the Intellisense window, Eclipse has a similar function for Java.

Mixing coding styles makes it hard to read the code and find members via AutoComplete.

So you should apply company-wide coding guidelines, use them and correct wrong names.

For the .Net Framework I recommend to use the Naming Guidelines for the .Net Framework. You can check your Assemblies using a tool called FxCop from GotDotNet.com. FxCop also provide checks for performance, design and security issues.

You can also specify custom rules if the existing rule library doesn’t fit your needs.

A good way to enforce coding guidelines to all developers is to add the code formatting settings to the Active Directory. These settings are saved in the registry, so you can import or export them easily.