in reply to if else and not reachable coding style

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).


No good deed goes unpunished. -- (attributed to) Oscar Wilde
  • Comment on Re: if else and not reachable coding style