Propagating NEVER use else doesn't make much sense for a post tagged with #functional, because it is synonymous with NEVER use FP. FP is about expressions that must evaluate to values, which obviously doesn't work if you drop the else branch. OOP on the other hand is about statements that evaluate to nothing but perform side effects. So expressions stand for pure values whereas statements stand for impure effects.
It is not bad because you don't return early but because you rely on side effects in the first place. I think you made a really important observation but drew the wrong conclusion. Your example is simple and contrieved. Think about a huge program with side effects. I don't think that exiting early will save you in the long term but abandoning side effects will.
Propagating NEVER use else doesn't make much sense for a post tagged with #functional, because it is synonymous with NEVER use FP. FP is about expressions that must evaluate to values, which obviously doesn't work if you drop the
else
branch. OOP on the other hand is about statements that evaluate to nothing but perform side effects. So expressions stand for pure values whereas statements stand for impure effects.Regarding your example:
It is not bad because you don't return early but because you rely on side effects in the first place. I think you made a really important observation but drew the wrong conclusion. Your example is simple and contrieved. Think about a huge program with side effects. I don't think that exiting early will save you in the long term but abandoning side effects will.
Thanks for the comment.
One of the way's I like to think about avoiding side effects is this returning thought process :)