2 ms·
Have you measured this benefit in any empirical way? It is a bit dated now, but Code Complete cites actual attempts to study the connections between function l
by btilly 11y ago
Have you measured this benefit in any empirical way?
It is a bit dated now, but Code Complete cites actual attempts to study the connections between function length and maintenance cost in real world code bases. The conclusion was that functions with a high internal complexity were maintenance hazards. Basically add up all of the if's, loops, and so on, and if that is a big number, then break it up. However long functions without internal complexity were not a maintenance hazard. This was true up to about 200 lines.
OK, a lot has changed since IBM studied maintenance costs in the 1980s. But the received wisdom today about short functions was already the received wisdom then. And the wisdom today is just as much based on opinion as it was then.
Is there any more reason why we should accept the received wisdom today than there was then?
- eru 11y agoGood points. My argument was actually mostly from a Haskell point of view, and a study there would be somewhat harder to define: you are defining functions all the time: especially in imperative code (do-block / monads) each line is actually a callback. You could go by purely syntactical criteria, though. Culturally, even a single screenful of code is considered rather long for one definition in Haskell.