[Tutor] How (not!) lengthy should functions be?

boB Stepp robertvstepp at gmail.com
Sat Apr 18 21:30:12 CEST 2015


On Thu, Apr 16, 2015 at 4:03 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 16/04/15 17:47, boB Stepp wrote:

[...]

> 2) I have seen varying recommendations as to number of lines of code
>
> Most of these come from the days when we worked on dumb terminals with 24
> line screens. Actual measurements has shown that function length (within
> reason!) is not a major factor in comprehension or reliability. In COBOL or
> C it is not unreasonable to have functions over 50 lines long, sometimes
> over a hundred. But in Python that would be very unusual. So I'd treat the
> advise to limit length to about 20 lines of executable code to still be
> valid, if you exceed it treat it as a red flag to check that you really need
> it to be that long.

Would not your comments above apply to line length as well? If yes,
why are we still wedded to a 79-80 character limit to lines when most
people's monitors are quite expansive, to put it mildly?

boB


More information about the Tutor mailing list