I strongly prefer the third option. Most of the subroutines I write have some sort of 'short-circuit' condition such that the majority of the code will not be executed (parameters invalid or incomplete, etc.). I find that when I use the first option, I usually end up duplicating code that could be factored out. I would never use the second example -- by definition, an if/else construct covers all possibilities, COND and !(COND).
In reply to Re: if else and not reachable coding style
by ptum
in thread if else and not reachable coding style
by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |