Jerry Nixon @Work: Our standard C# naming conventions

Jerry Nixon on Windows

Wednesday, September 16, 2009

Our standard C# naming conventions

Everyone has their own coding standards. The most important thing is that you have standards – and if you are part of a team that you share and obey standards. Standards help developers on the team during development and during maintenance. Be consistent, and if you can – be smart about it.

The MSDN conventions are the source of my personal conventions. I thought I would share my preferences around case. This is how my developers standardize their code and a few of the rules we use. Just by looking I can come guess within 99% of exactly what objects are just by their case.

You might have your own preferences, but at least be consistent.

This just happens to be what I like and use:

ExampleStandardWhat is it?
m_JerryNixonm_ prefix, Pascal CaseClass member variable
_JerryNixon_ prefix, Pascal CaseLocal variable
JerryNixonSimple Pascal caseProperty
OnJerryNixonOn prefix, Pascal CaseEvent
JerryNixonsPlural Pascal CaseEnumeration
JerryNixon()Simple Pascal caseMethod
jerryNixonSimple Camel CaseMethod parameter
JERRYNIXONUpper caseConstant


Our overarching rule is – no abbreviating. And although there are a few more rules, I like to keep them slim. Developers like freedom.