C# Coding Standards

 Download Lance's C# Coding Standards v1.1.5

I started my C# Coding Standards document back in the early days of .NET and C#.   The very first incarnation was for my employer in response to an incoherant mess created by a dozen developers who coded to their own drumbeat.  We sought agreement on everything starting from tabs vs spaces, curly braces, and naming conventions.   I made a first stab at a document, and it was quickly ratified as our standard with only a few tweaks - everyone was pleased and started making their code 100% match the standards.   Note: it was quite a tome! Over 12-pages long, guaranteeing that outside of this one effort nobody would ever read it again, let alone follow its "wisdom".

As my understanding and usage of C# evolved, I became ever dissatisfied by the result of my first endeavor and made attempts to revise the coding standards and further evolve it.  Unfortunately, adoption of these changes was was met with resistance as the committee who approved the document was satisfied and saw further revisions unneccessary - thus it became etched-in-stone.   Beyond the oppressive girth of the document, I considered the end result a complete failure because coding standards should be an ever-living and growing entity that reflects your team's evolving perception of best practices over time, not a paperweight to burdon the desks and inboxes of developers.  As a result, I decided to start my own coding standards and share it with the world.

This document (or its earlier naieve incarnation) is the result of that rebellion against immutable C# Coding Standards.   Its primary goal was to come up with a concise set of guidelines that could be quickly consumed as either a reference or a quick read-through.   I continued to tweak and revise for several years until apathy, work, and family needs overcame my ability to maintain it further.

Since then my document has been adopted, translated, and used as the inspiration for thousands of teams' coding standards all over the world.   For that, I am forever flattered.  Ironically, because I stopped publishing my C# Coding Standards in 2007, I fear that now I have created a bigger problem - yet another non-evolving coding standard.  For the many people who have been oppressed due to my document's inertia - I am forever sorry.

Today I feel that coding standards are enforced excessively and that a more minimalistic approach to coding standards is more appropriate for most teams.  However, until I decide to revise this document yet again, or help those who want a baseline from which to evolve their own coding standard,  I preserve here, my last known good version of my C# Coding Standards document for those still interested in using it as an inspiration for their own teams - please use it only as a starting point from which you can evolve your own standards.

Thank you.

Lance Hunt

Release Notes:

v1.15 -  03/01/2007
  • Added numeric datatype usage guidelines.
  • Adjusted guidelines for public, protected, and internal access modifiers.
  • Tweaked verbage throughout document.
v1.13/a -  08/17/2004
  • Modified layout & added License Agreement. Misc. grammar adjustments.
  • Removed rules on foreach vs for pending additional research. 
  • Added rules on switch/case statements. 
  • Revision(a) recommends custom Exceptions to subclass Exception not ApplicationException
v1.12 -  06/30/2004
  • Modified code commenting and formatting rules. 
  • Modified various code examples.
  • Modified Exception Handling and Flow Control sections.
v1.11 -  06/08/2004
  • Modified formatting. 
  • Restructured “Language Usage” section. 
  • Corrected language, and added code examples. 
  • Consolidated conflicting rules.
v1.10 -  05/25/2004
  • Modified naming conventions for Internal and Protected identifiers. 
  • Added, modified, & removed misc rules. 
  • Corrected grammar, code, and some verbiage.
v1.09 -  05/23/2004
  • Changed style & formatting. 
  • Added Quick Summary tables. 
  • Added/modified various standards.
v1.08 -  05/20/2004
  • Split .NET guidelines into separate document.
  • Changed overall scope and goals. Restructured sections. Improved Introduction.
  • Added Scope and Terminology sections.
v1.07 -  05/11/2004
  • Added Bibliography, Resources, and .NET Framework Guidelines.
v1.06 -  05/10/2004
  • Misc. adjustments to various rules.
v1.05 -  05/10/2004
  • Updated Naming Conventions.
v1.04 -  05/09/2004
  • Misc. grammar and syntax changes.
v1.03 -  05/09/2004
  • Changed formatting and organization.
v1.02 -  05/09/2004
  • Added code examples.
v1.01 -  05/09/2004
  • Added more Language Usage.
v1.00 -  03/01/2004
  • Created