DEV Community


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

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.

opwernby profile image
Dan Sutton

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