Re:Ask HN: What did the really successful programmers do dif...
by takeda64 on Monday October 08, 2012 @08:06PM
(#4629286)
Agreed. Same for using goto in C for error handling (e.g. http://www.xml.com/ldd/chapter/book/ch02.html#buierr) I found this used often in Linux kernel and I absolutely love it how clear it is.
Re:Ask HN: What did the really successful programmers do dif...
by bzdzb on Tuesday October 09, 2012 @05:15PM
(#4633983)
I agree. The alternative as you state is nested conditionals. Yuck! An alternative construct I have seen and used is to wrap code in a do {} unless(0) block and break to a single failure return or complete the block to a single success return.
The alternative to early exits is nesting, and nesting is the readability killer. My experience has apparently been just the opposite of yours: that avoiding early exits is a sign of a junior programmer, and returning early whenever possible is a sign of an experienced programmer who knows that understands code maintenance.