Naming Conventions in C#

Last week I had a chance to talk to one of my friend about the naming convention they are using for their projects. He went to on to great details on how they have standards in naming convention. In my opinion, developers shouldn’t think too much about standards before writing every single line of code. The standards should be natural for development which help maintenance rather than taking developers productivity down since they have to think twice before writing code.

One thing really stick with me was the rules they use for naming convention. They have very elaborate rules on class name, method name etc.,

I like the following simple rules for naming variables;

(Names should be meaningful and easily understandable.)

Use first letter capital for for all Methods/Properties.

Use _ as the first letter for private variables. I have seen people use m_ or my as prefix for private variables.

Use first letter lower case for all method parameters.

This goes with another idea of using properties instead of private variables. There was a discussion on this topic so I am not going to go into details.I prefer to use Properties rather than private variables. By making private variables with _, it will be easy to add a FxCop rule during file check in to see if anyone violated the rule easily.

Everyone uses different rules that suits their development.