5 ms·
> Early returns reduce the complexity of a method by reducing the number of possible states as you move through the method. As I said in other comments, early
by glastra 11y ago
> Early returns reduce the complexity of a method by reducing the number of possible states as you move through the method.
As I said in other comments, early returns for exceptions and bad input are fine. They are exceptions, though, not return statements. Go ahead and use return if you want/can, although I wouldn't.
If it's not for an exception or input validation failure, then we have something like:
"Alright, so here we do this, unless this, that and that other condition over there were true earlier, because the method would've returned then..."
I find that the complexity to keep track of with this approach is pretty much the same, or even more depending on the branching.