2 ms·
> Short circuit returns are the devil No, they're not. > they make it much harder to factor out part of a function into a smaller function They generally mak
by gnaritas 13y ago
> Short circuit returns are the devil
No, they're not.
> they make it much harder to factor out part of a function into a smaller function
They generally make the function smaller, that's what guard clauses are for.
> A function should have one entry point and one exit point
That's absurd and makes for very ugly and unnecessary code.
- lmm 13y ago> They generally make the function smaller, that's what guard clauses are for. My point is: frequently, one wants to extract a part from the middle of a function to make a new function. This is very easy (and can usually be done automatically) unless said part contains a return.
- gnaritas 13y agoSuffering the unbearable burden of a single exit point just so your refactoring tool has an easier time breaking up the code isn't a trade worth making, especially when it's the single exit point that's probably making it too long to begin with.