3 ms·
If you don't use early returns don't you end up with functions doing lots of state/variable mutation (within the function)? Thats what I consider the problem wi
by DogLover_ 7y ago
If you don't use early returns don't you end up with functions doing lots of state/variable mutation (within the function)? Thats what I consider the problem with big function and/or not using early returns. You then need to keep track of all those modification. I find it much easier to reason with early returns.
You can certainly over-engineer things just to avoid bigger functions. However from my experience I see that far less than complicated large functions with little care to readability.
- quadcore 7y agodon't you end up with functions doing lots of state/variable mutation (within the function)? Good question. This is true, but this is a programming language bug. In some programming language you can write the equivalent of return if... or return for.... Also note that those intermediate variables add a lot in expressiveness (you're computing result or screensize etc). The mutation is unfortunate indeed but a programming language bug.