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:
However, I started questioning this habit in a particular case: when the failure in a condition should cause the method to abort right away.
- 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.
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: Early Aborts, Single Point Return, Flow Control, Method returns, Flow of Execution, Conventions, Programming Style
No comments:
Post a Comment