Friday, March 06, 2009

New coding guidelines for C# 3.0

Update June 29th, 2010
This document has just gone through a major update for both C# 3.0 and C# 4.0. Read more about it here and get the document from

I have been a long-time supporter of coding standards because I believe in its value as a way of improving overall code quality and helping inexperienced developers to gain more insight on the consequences of their work. I wrote my first C# Coding Standard together with Vic Hartog in 2003 for Philips Medical Systems, but have been refining these since then. However, I think every architect or lead developer should decide for himself whether or not he or she wants to comply with each and every rule, so I decided to refer to this document as Coding Guidelines rather than Coding Standard.
In the last couple of months I’ve been busy trying to revise this original document in order to come up with a version suitable for C# 3.0. And since Visual Studio has great support for automatic code checking using its Static Code Analysis feature, I decided to remove any overlapping rules and guidelines. The new document should be used as a companion to Code Analysis/FxCop and adds additional best practices that have proved to be very useful in my daily work as a consultant.