views:

161

answers:

4

I'm about to undertake updating our coding standards documentation and I am thinking of perhaps writing them at a somewhat higher level than is commonly done. We have a fair amount of developers that come and go, and they are generally of an intermediate skill level. I want to eliminate the low quality "fluff" sections...for example, "variable naming conventions", etc...anything that is really of dubious value, that distracts from the portions of the document that are of genuine value (which may be skimmed or skipped entirely due to excessive low value content).

I am also more interested in ensuring people don't do stupid things, rather than forcing them do do things in a certain way.

We happen to be a .Net / Oracle shop, but for the type of material I am looking for, I don't think language is particularly important.

I'm wondering if anyone has done this before and have some material they wouldn't mind sharing, or has come across any good online material of a similar nature?

+1  A: 

The guidelines for class developers on MSDN has a lot of good material. Lots of low level stuff like you want to eliminate and it's definitely more on the practical side, but worth a look.

JP Alioto
A: 

Perhaps just one section on following guidelines posted by JP or that code should pass FxCop with some minimum score, so that those things are covered and devs have no excuse for not doing them. That will leave more space in your standard for domain-specific guides.

Joel Coehoorn
+4  A: 

In my experience, the practical value of a coding standard is proportional to its ability to be automatically measured. Part of our shop's C# coding standards (which fit on one page) say that the code must be clean according to the default rules of both FxCop and StyleCop. Both tools can be run by the developers as well as the build process.

jalbert
StyleCop will define your coding style standards. It's quite inflexible and that's a GOOD thing - you do what it tells you and you stop arguing about where to put your curly braces (those that continue to argue should read Joel's "Best Software Writing"). FxCop will keep you on the right track when defining APIs. Here, you can tell it to ignore (surpress) certain issues, but you are at least told wha the best practice is.
Martin Peck
I agree about the "ability to be automatically measured," but I don't agree about using the default rules for both FxCop and StyleCop. e.g. CA1805 - DoNotInitializeUnnecessarily, CA1016 - MarkAssembliesWithAssemblyVersion, CA1044 - PropertiesShouldNotBeWriteOnly c.f. http://www.paraesthesia.com/archive/2008/10/30/fxcop-rule-recommendations.aspx
Lucas B
+4  A: 

I definitely prefer a tooling option ReSharper over a standard document. The more I develop professionally, the more I realize that coding standard documents are a waste of time and they tend to be a productivity drain.

Code should be readable and understandable. Unfortunately, a coding standard cannot enforce either. Tools, however, can at least enforce naming conventions and help find problems such as failure to check for null, or "access to modified closure".

Whatever the case, a coding standard should never keep developers from writing good code. I have seen documents that forbid the use of ternary operators or operator overloads. I have also seen documents that require that code be well commented (I try to avoid comments at all costs in favor of readable code). None of these things, in my opinion, should be in a coding standard.

Brian Genisio
This is the first time I have felt I needed to be able to vote more than once on a particular answer. Note - in the past I was very gung-ho on code guidelines/standards. I now fall squarely in Brian's camp.
Tim
some use of peer reviews will go further than coding standards. You actually get a better work product, whereas with a document you get nothing out of it.
Tim
I don't care what the coding standard is, since one is usually as good as another. Just don't make me think about it. For this reason, I think the most sensible standard is to just use the R# defaults. It's a decent standard, and there is nothing extra you need to do in order to make it obvious when it's being violated (except maybe convince your coworkers to use R#.)
Josh Kodroff