I know we discussed indent styles once before, but I figured we might as well do it again. This time, I figured we might as well make it a poll and see which of these styles appears to be the most popular one.
Since not everyone knows these styles by name, let me give you an example of each one to refresh your memory. Usually, most programmers only acknowledge one true indent style and consider all the other ones an unholy abomination unto God. So here are the styles to pick from:
K&R
if (x == y) {
x++;
foo();
} else {
x--;
bar();
}
Allman
if (x == y)
{
x++;
foo();
}
else
{
x--;
bar();
}
Whitesmith
if (x == y)
{
x++;
foo();
}
else
{
x--;
bar();
}
GNU
if (x == y)
{
x++;
foo();
}
else
{
x--;
bar();
}
Horstman
if (x == y)
{ x++;
foo();
}
else
{ x--;
bar();
}
Pico
if (x == y) {
x++;
foo(); }
else {
x--;
bar(); }
Banner
if (x == y) {
x++;
foo();
}
else {
x--;
bar();
}
I actually prefer the Allman style. The braces should go underneath the opening block statement. I hate when the K&R people put them on the same line. All the other styles are just to bizarre.
How about you? Which style do you prefer?
====
http://www.terminally-incoherent.com/blog/2009/04/10/the-only-correct-indent-style/