[Tutor] functions--how long is too long?
rabidpoobear at gmail.com
Tue Dec 8 17:14:50 CET 2009
On Tue, Dec 8, 2009 at 4:17 AM, spir <denis.spir at free.fr> wrote:
> Luke Paireepinart <rabidpoobear at gmail.com> dixit:
> > I'd say my personal hard-limit for functions before I start refactoring
> > probably around 150-200 lines. But it's rare that functions get that
> > anyway.
> Aside questions of personal style & taste, _I_ could not hold such long
> funcs. Far too much to manage for my head, about unmaintainable for me.
> My common limit is about one editor screen (~ 35 lines), comments included,
> which reveals not only practicle, but also about what my head is able to
> cope with at once. And my programming style rather leans toward clarity (-->
> low code density), meaning that 1 line of a "smart" coder may map to 2 or 3
> of mine. An absolute limit would be about 2 screens.
> To sum up:
> 150 lines by luke
> * 2 (density)
> * 2 (comments)
> = 600 lines by myself
The 150-200 lines was including comments and everything else. And I just
meant that is the point where I would be forced to refactor. For shorter
functions that are unclear I would refactor before I got to that many lines.
But like I said, most functions I write just tend to be naturally much
shorter than that anyway.
I was just trying to point out that there is a point where you are forced to
refactor just because of the size, but before that point, refactoring may
actually make your functions more confusing and harder to follow. It's a
situational thing, which is why I asked for code originally.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor