I think it would greatly help reviewers if we decide upon and adopt guidelines on readability oriented coding conventions. A few examples:

Blocks

One space between arguments, no new line braces

if( condition ) {
// do this
} else {
// do that
}


if(condition)
{
// do this
}
else
{
// do that
}


No spaces after methods names

int funkyMethod(foo)


int funkyMethod (foo)


Proper identation

<html>
<div id="funky">
<p>Hello World</p>
</div>
</html>


<html>
<div id="funky">
<p>Hello World</p>
</div>
</html>


I'm aware that such a proposal has high potential of turning into a flame war. I'm not suggesting we adopt the above examples, they are just examples, what I'm saying is that adopting common conventions is more important than what those are. Sensible conventions is the first step to any code review, providing them in the faq or in meta discussions as references will provide common ground for askers and editors

I'm in no way suggesting that we try to enforce our conventions to anyone, just providing a generic template for editors and experienced askers to format code in questions and answers. Such a guideline should be geared towards making code more readable first and smaller then. Small is good, since we have certain limitations at the amount of code that is shown in a code block at once.

Of course, same conventions will not apply to all languages. The python people especially will laugh out loud at our indentation peculiarities. But we could start with guidelines for C style languages, as the family is more popular.

As for how the adoption could work: We could brake suggestions into meta discussions and let people vote on which style they prefer.

Thoughts?

• Why? I don't see what the point is in trying to come up a coding convention on a code review site. Sure following a convention is important, but I'm not seeing how having our own convetion would serve any purpose. Nov 14 '11 at 13:56