Question: I've worked on a couple of projects where we spent a great deal of time discussing and writing elaborate coding standards covering everything from syntax layout to actual best practices. However, I have also found that these are rarely followed to the full extent. Many developers seem to hesitate to reject a code review based on coding standard violations alone. I.e. violations are committed to the repository on a regular basis. 

My questions are: Do you have coding standards? What do they cover? Are they followed by everyone? And what do you do (if anything) to make sure everybody is following the standards?

I'm aware that there is a similar question [here](https://stackoverflow.com/questions/167575/should-a-project-manager-enforce-coding-standards), but my concern is not so much how you could do it, but how you are actually going about it and what are the perceived benefits?

Answer: 
I think coding standards are very important. There is nothing more frustrating than trying to find the differences between two revisions of a file only to find that the whole file has been changed by someone who reformatted it all. And I know someone is going to say that that sort of practice should be stamped out, but most IDEs have a 'reformat file' feature (Ctrl-K Ctrl-D in Visual Studio, for example), which makes keeping your code layed out nicely much easier.

I've seen projects fail through lack of coding standards - the curly-brace wars at my last company were contributary to a breakdown in the team.

I've found the best coding standards are not the standards made up by someone in the team. I implemented the standards created by iDesign ([click here](http://www.idesign.net/idesign/download/IDesign%20CSharp%20Coding%20Standard.zip "IDesign Coding Standard")) in our team, which gets you away from any kind of resentment you might get if you try to implement your own 'standard'.

A quick mention of Code Style Enforcer ([click here](http://joel.fjorden.se/static.php?page=CodeStyleEnforcer "Code Style Enforcer")) which is pretty good for highlighting non-compliance in Visual Studio.
> 
> Do you have coding standards? 
>  What does it cover? 
> 
> 
> 

Yes, it has naming conventions, mandatory braces after if, while ... , no warning allowed, recommendations for 32/64 bits alignment, no magic number, header guards, variables initialization and formatting rules that favor consistency for legacy code. 

> 
> Is it being followed by everyone? 
>  And what do you do (if anything) to make sure everybody is following the standard?
> 
> 
> 

Mostly, getting the **team agreement** and a somewhat lightweight coding standard (less than 20 rules) helped us here. 

> 
> How it is being enforced ? 
> 
> 
> 

Softly, we do not have coding standard cop. 

* Application of the standard is checked at review time
* We have template files that provide the standard boilerplate