How do you indent your switch statements? My boss prefers
switch(x) {
case 1:
...
case 2:
...
default:
...
}
while I am steadfastly (stubbornly?) clinging to
switch(x) {
case 1:
...
case 2:
...
default:
...
}
Of course, in this case, the former is the correct style.
Really, this is not one of those things that makes a hell of a lot
of difference and I wouldn't risk my paycheck over it.
If you use 8 column tab stops, either a TAB is eight columns, or you use
eight spaces (lets not get into that argument) then the first method is
desirable. The first method is also K&R style. Why do K&R put the case
labels where they do? Probably because they are much like labels used for
goto and those always go clear to the left of the scope, so it seems
reasonable to put the case label clear to the left in their scope. This
being said, the second method I see quite a bit as well.
I think it is more important to maintain consistency. Unless the rest
of a system is absolutely horrendous or completely lacks some form of
style, then I would be more concerned about remaining consistent with the
rest of the code. As a general rule I find those that are too careless to
maintain consistency are unable to write good code at all.
So if you're writing code I think you should follow whatever group or
corporate standards document is provided in order to keep the code as
consistent and professional looking as possible. If you have a non
religious gripe with the coding standard then you should petition to have
it changed. I don't think something like this would qualify as
non-religious.