views:

278

answers:

8

Does your team develop its own coding guidelines? How long is the document? How often do you read/need it? How often do you make mistakes by not abiding to the guidelines?

Who has permission to edit it?

A: 

Yes we do only a small group actually make edits and distributes new versions, but we are very much open to discussion and dialog.

We try to take this seriously as many customers have also ask us for our guidelines and do share them.

Jim C
+3  A: 

Most of the development teams I've worked with have had coding guidelines.

Most of the guideline documents I've seen average 5 to 15 pages.

I find that once I've studied the guide I don't need to refer to it very often at all.

I've found that the guidelines rarely need to be edited and when they do, the team usually does it together.

Most mistakes are found during code reviews and don't happen very often unless the guideline is something really weird.

We had a guideline that stated that there must be a space between each parenthesis and the next character, like ( chars ), which I found pretty onerous - I broke that a lot. I think VS 2005 won't even let you do that or at least it defaults to removing those spaces.

This link goes directly to Juval Lowy's excellent c# coding guidelines. It's a great place to start.

Terry Donaghe
why does everybody split { into new lines from function() and for()? I feel so alone.
Haoest
After looking at code for years and years I find having {'s and }'s on their own lines MUCH more readable.
Terry Donaghe
@Haoest - I hear you. I don't like open curly braces on their own line either. However, my main reason for doing it anyway is because that's the way Visual Studio wants it. I either have to turn off auto-formatting and do _all_ the formatting myself or live with open curlies on their own line :(
whatknott
Tools -> Options -> Text Editor -> $Language -> Formatting.
Jasper Bekkers
A: 

Yes we did. One person edited it and did an excellent job on it. You would typically read it when first joining the group and had nothing better to do. No one edited it later since no one was interested or had the time. Many of the guidelines were motivated by readability and the ability to easily step through individual lines of code in softice, or to eliminate errors related to debugging code. The coding standards were treated company secret. About 10 pages.

P a u l
A: 

We (a C++ team) use the Google C++ Style Guide with a couple of modifications. The important thing is to be consistent and the Google style is a great place to start IMHO.

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

Rob
+2  A: 

If you're doing .Net development, I would recommend this. It bascially sums up Microsoft's recommended conventions (with a few changes) and can almost be put into a single page.

My goal with our coding standards was to keep them short and keep them consistent with the framework. From past experience, I can safely say that long, unconventional standards don't work. If a developer has to read 50 pages to learn them they just don't get followed.

whatknott
A: 

In languages where they're available -- eg, C with indent -- instead of detailed coding guidelines, or in addition to them, publish a standard reformatting command. Code can then be normalized in a simple operation.

Beyond that, just be cautious of fancy style guidelines; you can waste a lot of time on religious disputes over

}
else
{

versus

} else {
Charlie Martin
Well, I prefer the first one because the braces match in that case, in the second one they don't and the division between both code blocks might not always be more clear. (Also, code tends to stick next to that line which decreases readability)
TomWij
See? After a long time using the first, I finally converted to the second becase its more symmetrical, and because line changes can't get confused.
Charlie Martin
A: 

We sat down and hashed them out in about half an hour, and they fit on a sheet of notepad paper. Mostly naming conventions for classes, methods, properties, global variables, function variables, etc. I needed to refer to them a few times the first day and haven't since. My junior colleague has needed to be reminded of them several additional times. :)

chaos
A: 

Generally, it is better to stick to industry standards than reinvent the wheel.
Depending on platform we use, there are

Ihar Voitka