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].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to