cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Unico Hommes <un...@apache.org>
Subject Re: Eclipse 3.1's "Unnecessary else statement"
Date Thu, 09 Jun 2005 10:36:05 GMT
Carsten Ziegeler wrote:
> Sylvain Wallez wrote:
> 
>>Hi all,
>>
>>I noticed for a while that many commits are related to "making Eclipse 
>>happier" because of an additional 3.1 feature that flags "unnecessary 
>>else statement".
>>
>>These changes are for constructs such as:
>>    if (condition) {
>>        return foo;
>>    } else {
>>        return bar;
>>    }
>>
>>which are changed to:
>>    if (condition) {
>>        return foo;
>>    }
>>    return bar;
>>
> 
> 
>>So please, update your settings and leave unchanged what doesn't need to 
>>be changed :-)
>>
> 
> Oh no, you're starting one of the famous code formatting threads...I'm
> just waiting for someone pointing out that the brackets should be in a
> new line...

Just for play, here is my religion: I believe it is only control
statements that need to start on a new line, brackets are merely
punctuation:

if (condition) {
  return foo;
}
else {
  return bar;
}

:-P

> Seriously, I think a method should only have *one single* return
> statement, which makes imho code even more readable.

Seriously, you have a point. But I don't think it is worth the effort to
argue it or to have everyone abide. The "unnecessary else statement" fix
Sylvain points out is indeed silly as the proposed improvement by
Eclipse results in code that is actually less clear.

--
Unico


Mime
View raw message