3 ms·
In my experience, there's a "sweet spot" for how much functionality a method "should" have. If a method is "too short", it: * may result in methodA calling met
by nickh 18y ago
In my experience, there's a "sweet spot" for how much functionality a method "should" have.
If a method is "too short", it:
* may result in methodA calling methodB calling etc., increasing complexity;
* may not be readily apparent how it fits in to the problem that's being solved.
If a method is "too long", its:
* complexity increases;
* ease of testing decreases;
* frequency of reuse decreases.
Obviously, some methods have little functionality, and thus require very few lines. For the majority of the other methods, though, I tend to keep them below 25 lines. If a method grows past 15 lines, I examine it to see if there's any functionality that feels like it should be broken out into a separate method.