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

Dave Smith dave at thesmithfam.org
Sat Nov 4 20:48:30 MST 2006


Levi Pearson 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.

And you probably always will, for the following reason:

For me, readability has more to do with consistency than white space 
usage or brace placement. I personally have become accustomed to this style:

   if( something )
   {
       return false;
   }

So, things like this just cause me to have to mentally tokenize the 
code, rather than speed read through it:

   if( something ) { return false; }

I don't think either style is more or less readable, inherently, but my 
mind has been trained to read the former, so I process it more quickly.

I used to optimize my code layout for vertical compactness, but I don't 
feel it has made any difference for  the readability of my code *to me*. 
There are many better ways to make code readable than white space, I've 
found, and they all have more to do with well thought-out logic and good 
design.

Just my quarter million Turkish Lira.

--Dave



More information about the PLUG mailing list