C++ style question/criticism, was Re: Mozy Contest Answers

On Sat, 04 Nov 2006 18:09:50 -0800, Levi Pearson <levi at cold.org> wrote:
> Why, oh why, do you use so much darned extra space in this code? It's
> an incredibly inefficient use of both vertical and horizontal space.
> What is the point of putting curly braces on lines all by themselves?
> Again, I don't mean this as a personal attack, just an honest bafflement
> at a programming style I've seen used fairly frequently.
Some people find it easier to match up blocks of code when they have curly
braces by themselves. For example, given:
while (getline(cin,str)) {
... lots of code here ...
}
they find it difficult to see the "while" line at a glance when trying to
find the line that begins the block.
I personally find that, after using the above style for a while, you
become accustomed to it and it becomes just as easy to locate the opening
block despite the lack of a curly-brace on a line by itself. I greatly
prefer the curly-brace-on-same-line style myself, to save on the vertical
space. But that's the answer I've heard from every person who prefers the
curly-brace-on-separate-line style--that it's easier to match up blocks of
code.
With regards to horizontal space, that's simply a tabs-versus-spaces
argument. If you have your email reader tabstops set to four spaces, the
horizontal space is identical in both. I'm sure you've heard that debate
plenty of times, so I'll not repeat it here. :-)
~ Ross