I agree, it's rubbish code.  Not a single person here defended it.

Explicit return types and checked exceptions alike *force* you into handling
something, which is sometimes necessary, but more often not.  I'd view
either with suspicion if it obfuscated regular expected behaviour in the
code.

But... if you're being forced into handling something it must be expected
behaviour and so, by definition, not exceptional.  Pushing such logic to the
end of a try/catch block is therefore *also* obfuscating 'normal' program
control flow.


2010/9/22 Cédric Beust ♔ <[email protected]>

>
>
> 2010/9/22 Cédric Beust ♔ <[email protected]>
>
>> The approach you are recommending leads to this kind of spaghetti 
>> code<http://www.kirit.com/Handling%20COM%20errors%20in%20C%2B%2B> (C)
>> or this 
>> one<http://stackoverflow.com/questions/2137357/getpasswd-functionality-in-go/2138163#2138163>(Go).
>>  In these two examples, notice how the error handling is completely
>> polluting the logic and making the code hard to follow.
>>
>
> I just took a closer look at this code and it's actually even worse than I
> thought. Take a look (this is Go):
>
>     pid, err := os.ForkExec(stty_arg0,stty_argv_e_off,nil,exec_cwdir,fd);
>     if err != nil {
>         return passwd, os.NewError(fmt.Sprintf("Failed turning off console
> echo for password entry:\n\t%s",err))
>     }
>
> Not only do errors need to be checked at each step of the way, but the
> programmer is actually forced to simulate bubbling up manually. Which means
> that the calling method will have to contain similar code, and then its
> caller, and then its caller, etc...
>
> Really horrible.
>
> --
> Cédric
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>



-- 
Kevin Wright

mail / gtalk / msn : [email protected]
pulse / skype: kev.lee.wright
twitter: @thecoda

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to