Hi!
As anyone who has had a look at, what I have done so far can see, I have made quite a mess with the formatting of the code, primarily using tabs for indentation and occasionally panicking with the format and dropping to 2- or 4-space indents and the coming back.... I have been thinking, that before anyone does anything else, I should perform a "grand white wash" to the files, that I have created or edited but before that I'd like to make a suggestion about the formatting.
Now the guideline says, that the indentation style is 2-spaces, but I'm wondering, what the reasoning behind this instruction is or if the reasons are really valid nowadays?
I've got a feeling, that this practice pretty much comes from the era of VGA displays or before, where you could realistically fit about 20 lines on an editor screen and max 80 characters on a line. Nowadays displays are a lot larger. You can easily fit 60 x 200+ characters on the screen and with the latest toys even more.
While the 2-space indent saves space on small resolution displays, on large ones the presentation begins lose clarity of structure. At least that is very strongly my own perception of it. To me writing in 4-space indents makes the code much easier to browse and to keep track of the 'big picture'. Also (though this is really no argument here) Java examples on Oracle are written with 4-space indents and as I might guess, for very similar reasons.
Sure, there would be no point in starting to modify all of the code base into a new style but I'd suggest, that I'd clean/edit the new files (of my writing) and the ones, that I have heavily edited to 4-space indents. This would be rather easy to do even with files of currently mixed styles, while converting tabs to spaces.
While I'm at it, I might (where I find it bothering me) do some other minor styling as well: In my experience for example this
if(something)
{
doThis();
}
else
{
doThat();
}
is somewhat confusing to read especially, when the blocks get longer or when there are more similar indents inside the blocks. To me this would be more logical to follow:
if(something)
{
doThis();
}
else
{
doThat();
}
Then especially in cases of if-without-else or a short(ish) for, I might go:
for(something){
doThis();
doThat();
}
What works better seems to depend on, what is inside the block. At least, if there are more blocks, I'd probably want to drop the first brace on it's own line. The examples above are in 2-space style and currently you can find all of the three in different parts of the code, depending on when each piece was written.
So, what do you think? Would you find modernization to 4-space intents, with some other minor flavors reasonable in the mentioned cases or should I strictly stick to the old rules?