3 ms·
Yes, but how long a method does it take to make you claim it is a smell? One of Steve McConnell's books lists a couple of studies that suggests optimal method
by stonemetal 11y ago
Yes, but how long a method does it take to make you claim it is a smell? One of Steve McConnell's books lists a couple of studies that suggests optimal method length between 100 to 250 lines of code.
- derrickdirge 11y agoSmelliness generally increases proportional to length, simply by virtue of the fact that it takes longer for my human brain to parse. A one line function has no inherent smell because usually I can tell immediately if there's anything else smelly about it. A 250 line function smells a bit more since there are more places for more insidious smells to hide. Very short methods tend to be very easy to reason about. What properties of 100-250-line methods make them optimal?
- stonemetal 11y agoNumber of bugs per method.
- DonaldFisk 11y agoHow long ago were the studies made? One thing that's changed since then is the disappearance of continous form printing. Decades ago, you could print a 250 line function on four connected pages and lay them down on a table and see the entire function. Nowadays, reading printouts like that is unheard of.