Friday, May 12, 2006

Otaku, Cedric's weblog: Learning to like early aborts

August 01, 2005
Learning to like early aborts

I am a big fan of single return point functions.

There are several advantages to this approach:

  • Clearer flow of execution. You know the final return result will be run, no matter what.
  • Easier to debug. I can set a breakpoint on the return and inspect the returned value.
However, I started questioning this habit in a particular case: when the failure in a condition should cause the method to abort right away.

Otaku, Cedric's weblog: Learning to like early aborts

I have to admit to sticking fairly religiously to Single return point functions, after reading the comments from so many people that favour early aborts - maybe I should reconsider my position.

technorati tags: , , , , , ,

No comments: