DEV Community

loading...

Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

Collapse
ifieldhouse profile image
Ian Fieldhouse

"have only one point of return in it" is terrible advice. A great counterexample are guard clauses: they remove indentation and make code cleaner, making the flow of code easier to follow. Forcing you to have 1 return statement per function wil inevitable make your functions bloated.
If you are talking about the Dijkstra's Single Exit principle, then you are mostly misinterpreting him on a problem that doesn't exist anymore: when functions could return to multiple different places.

Collapse
opwernby profile image
Dan Sutton

Never mind: it's not as terrible as "don't use 'else' statements".