3 ms·
This x100. If you take a function and tell someone it's "too complex" and tell them to "fix it", that person will usually end up splitting it into, say, three
by ris 3y ago
This x100.
If you take a function and tell someone it's "too complex" and tell them to "fix it", that person will usually end up splitting it into, say, three functions. And now, you've just multiplied that complexity by all the different possible permutations of how/where the different functions can call each other. Corner cases that you could previously rule out because the control flow made them impossible are now fair game.
- kromem 3y agoExcept complexity as an issue is primarily about readability. Fine, a junior developer has a switch statement that's like 10 things long within a function with several if/else branches and they refactor to meet complexity limits by moving the switch to a function. As long as that function is well named, that's a huge improvement to readability. In part, complexity thresholds relate to human short term memory limits of seven plus or minus two.