2 ms·
Your logic has to flow somewhere. I prefer shorter functions too, but sometimes the actual “unit” is just not so concise without breaking it up in confusing way
by eyelidlessness 3y ago
Your logic has to flow somewhere. I prefer shorter functions too, but sometimes the actual “unit” is just not so concise without breaking it up in confusing ways. Handling edge cases first makes that much more digestible, IME.
- runarberg 3y agoForcefully breaking up your logic in places where it doesn’t make sense is an antipattern IMO, and makes it very easy to write spaghetti. I’ve inherited codebases with this overemphasis on very short functions and what I saw were very specific utility functions in dozens of different modules, all over the codebase, often with funky names, surrounded by dead code, and never a clear path to and from it. Sometimes a single function that spans even a couple of hundred lines, is preferable.