3 ms·
> Restrict the length of function bodies to reduce the probability of poorly structured code. We enforce a hard limit of 70 lines per function. Reminds me of C
by valyagolev 4y ago
> Restrict the length of function bodies to reduce the probability of poorly structured code. We enforce a hard limit of 70 lines per function.
Reminds me of Carmack on the benefits of long functions: http://number-none.com/blow/john_carmack_on_inlined_code.html http://number-none.com/blow/john_carmack_on_inlined_code.htm...
- Gibbon1 4y agoObligatory Hank Hill. I'll tell you hwhat. I've seen some poorly structured code with nothing but small functions. Like a state machine implemented via chains of callbacks that could all just live inside one big switch statement.
- dktoao 4y ago"Clever" developer limitation like this almost invariably cause developers to come up with even more convoluted solutions to problems than needed. Don't disagree that long functions can be an indication that someone was copy pasting a bunch of stuff around in the codebase, but not always!
- avgcorrection 4y ago70 lines is generous compared to Clean Code dogma/opinion.
- _vvhw 4y agoJoran from the TigerBeetle team here. The limit of 70 lines is actually a slight increase beyond the 60 line limit imposed by NASA's Power of Ten Rules for Safety Critical Software. In my experience, in every instance where we've refactored an overlong function, the result has almost always been safer.