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: 
Do you have coding standards?

> 
> 
> > 
> > Yes, differs from project to project.
> > 
> > 
> > 
> 
> 
> 

What does it cover?

> 
> 
> > 
> > Code(class, variable, method, constant), SQL naming and formatting convention
> > 
> > 
> > 
> 
> 
> 

Is it being followed by everyone?

> 
> 
> > 
> > Yes, every new entrant in project could be asked to create a demo project following organization coding convention then it gets reviewed. This exercise makes developer feel at ease before starting real job.
> > 
> > 
> > 
> 
> 
> 

And what do you do (if anything) to make sure everybody is following the standard? 

> 
> 
> > 
> > **Use StyleCop and FxCop** to ensure they are religiously followed. It would show up as **warning/error if code fails to comply** with organization coding convention.
> > 
> > 
> > **Visual Studio Team system** has **nice code anlysis and check-In policies** which would prevent developers checking in code that does not comply
> > 
> > 
> > 
> 
> 
> 

Hope, it helps

Thanks,
Maulik Modi
Our coding standards are listed in our Programmer's Manual so everyone can easily refer to them. They are effective simply because we have buy in from all team members, because people are not afraid to raise standards and style issues during code reviews, and because they allow a certain level of flexibility. If one programmer creates a new file, and she prefers to place the bracket on the same line as an if statement, that sets the standard for that file. Anyone modifying that file in the future must use the same style to keep things consistent.

I'll admit, when I first read the coding standards, I didn't agree with some of them. For instance, we use a certain style for function declarations that looks like this:

```
    static       // Scope
    void         // Type declaration 
func(

char   al,                //IN: Description of al
intl6u hash_table_size,   //IN/OUT: Description of hash_table_size
int8u  s)                 //OUT: Description of s
{
<local declarations>

        <statements>
}

```

I had never seen that before, so it seemed strange and foreign to me at first. My gut reaction was, "Well, that's dumb." Now that I've been here a while, I have adjusted to the style and appreciate how I can quickly comprehend the function declaration because everyone does it this way.