Rob Smyth

Monday, 29 October 2007

Coding Standards Without Having Coding Standards

Every developer likes a coding standard, so long as it is the same as theirs. :-)

Coding standards have benefit but only if accepted by the team. When I worked at Citect they had a strict published coding standard that had been in place for many years. It worked well and every developer complied. In other companies I've worked in have either not had a coding standard, I've implemented a documented coding standard, or the standard was 'copy the standard of the file you are working in'. But in the team I'm working in I've recently realised that a coding standard has been adopted by the team over the last few months without any documented standard, meetings, or negotiations. It just evolved effortlessly and has been accepted by all. The trick was automating the coding standard via Resharper's reformat code command. Nobody, well at least everybody but the implementer, even thought of it as a coding standard!

I can not take credit for this. In fact I was oblivious to it until I realised that we had a coding standard. Being automated meant that any/all files can be formatted with just a context menu command click. So easy, that it is attractive to everybody so everybody uses it. Resharper provides both a hint and positive feedback by a small indicator next to the editor window that goes green when the file is formatted to the rules you have set. It gives markers to lines that do not comply. So easy it is attractive and the good old green positive reinforcement.

Hmm ... are developers becoming conditioned to the green colour (red-green-refactor). Kermit was wrong, it is easy to be green.

No comments: