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

Alex Esplin alex.esplin at gmail.com
Sat Nov 4 21:20:34 MST 2006

On 11/4/06, Levi Pearson <levi at cold.org> wrote:
> There is more to readability than subjective opinions of beauty,
> though.  For one, if something is not visible, it is not readable.
> Therefore, my formatting was objectively more readable than the
> original.  That trumps some abstract and ill-defined notion of beauty
> in my book, though I happen to think mine looks much better anyway.

As far as vertical spacing and visibility are concerned, I use folding
on any loop or function more than 4 or 5 lines long, which _greatly_
increased the vertical real estate of my screen.  In gVim, the
following style:


In my folding (I use brace matching to create the fold) reduces to this:
+--- 4 lines:  if(foo){------

the other style of "curly bracing":


reduces in my folding to:
+--- 4 lines:  {---

As I stated in the other thread where this discussion started, neither
way is right or wrong (i.e. syntactically correct or incorrect).  As
such, given the fact that code being onscreen is a factor in
readability, I find the second way more readable for ____ reasons.
First, I can see the loop statement or function signature without
having to pick it out of the fold marker.  Second, I can create a fold
in this manner very quickly.  Third, this is the way I learned to
write code and the way I have written ever since.  Fourth, I have
never written code where there was a maximum number of lines to be
used.  In the absence of this constraint, I use whitespace freely to
"punctuate" and increase "find-ability".  For me, having the loop
condition or function signature separated from the code it encloses by
a line with nothing on it but a curly brace makes it easier to quickly
find a chunk of code and identify what it does while scanning through
the file.

I've probably beaten a dead horse even more, and I'm sure that no one
will ever agree to have one way standard.  That is fine with me.

Alex Esplin

More information about the PLUG mailing list