4 ms·
An individual function can quite reasonably be 500 lines long. A giant case statement handling routing is one example. More controversially, if I am gong to n
by Retric 6y ago
An individual function can quite reasonably be 500 lines long. A giant case statement handling routing is one example. More controversially, if I am gong to need to do a lot of ugly compatibility hacks then I prefer to consolidate them and thus keep most functions clean.
- awinder 6y agoCyclomatic complexity is one of the more well-rigorously studied measure of code quality, I don’t know if I’d pick that hill to die on.
- nemetroid 6y agoA function can be five hundred lines long without having high cyclomatic complexity.
- deleted 6y ago[deleted]
- Retric 6y agoThe average size of functions is independent of the programs total cyclomatic complexity.
- rcxdude 6y agoIt's rigorously studied but it's a crap thing to put an arbitrary restriction on, because it doesn't correlate well enough to warrent that. If you put a restriction on it, bad code still gets through fine while some good code gets made worse to bypass the checks (the biggest one is large switch statements acting as dispatch: Perfectly understandable, but if you split such a thing into multiple functions magically the cyclomatic complexity goes down to satisfy the linter but the code has just gotten harder to understand for static analysis and humans alike).