hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Templeton <Dan.Temple...@Sun.COM>
Subject Re: Hadoop coding style guideline
Date Tue, 01 Dec 2009 05:53:02 GMT
I have to weigh in strongly on the pro-braces side.  I've seen too many 
instances (not necessarily in Hadoop) where there was something like:

if (foo)
   stmt;
   otherstmt;

It's not about readability.  It's about maintainability.

Daniel

Doug Cutting wrote:
> Aaron Kimball wrote:
>> First, I've been picked on by others for using this brace style:
>>
>> if (foo) {
>>   stmt;
>> } else {
>>   otherstmt;
>> }
>>
>> and have been told to drop the braces because they look "ugly" if 
>> stmt or
>> otherstmt are only one line.
>>
>> In 
>> http://java.sun.com/docs/codeconv/html/CodeConventions.doc6.html#449though, 
>>
>> the sun coding conventions *clearly* say that braces are always to
>> be used. Can we get a ruling here?
>
> My preference is to permit both.  I like to maximize the amount of 
> readable logic per screen, and find that close braces around one-line 
> expressions don't improve readability (since indentation already 
> indicates the nesting) and decrease the amount of per-screen logic. 
> However I know reasonable people who prefer to always fully-bracket 
> their code.  I see no strong reason to force one style over the other.
>
>> And second, what's our story on tabs vs. spaces?
>
> Spaces are preferred, since tabs are inconsistently interpreted.  The 
> correct interpretation of a tab is to move to the next column evenly 
> divisible by 8, but many editors are configured differently, so tabs 
> are best avoided.
>
> Doug


Mime
View raw message