hadoop-common-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Milind Bhandarkar <mili...@yahoo-inc.com>
Subject Re: [jira] Commented: (HADOOP-948) Coding style issues
Date Tue, 06 Feb 2007 17:51:54 GMT
I agree with Owen that multiple returns (e.g. checking the validity  
of arguments first, and returning error codes, before doing the  
operation) do not hamper the readability of the code. There is  
clearly a discrepancy in sun's coding style conventions, because  
exceptions, which are multiple-level returns are allowed to be thrown  
any number of times in a single unit.

- Milind

On Feb 6, 2007, at 9:31 AM, David Bowen wrote:

>
>> Irrational fear of a second return has lead to lots of unnecessary  
>> code branches, in my experience. I'd rather see a return early in  
>> a function that a nested if branch that includes the rest of the  
>> body of the function.
>>
> I think it is entirely rational to avoid second returns.  (In cases
> where there are a lot of early-exit tests, I would agree that multiple
> returns are better than multiple nested if-then-elses.)  However, I
> looked up the Sun Java coding conventions and found no mention of  
> this,
> so I don't know of any authority to which I can appeal to support my
> case.  To me, code is more readily understandable if each unit has a
> single exit point.
>
>
>

--
Milind Bhandarkar
(mailto:milindb@yahoo-inc.com)
(phone: 408-349-2136 W)



Mime
View raw message