Pages as unit of measurement for source code?

I occasionally see pages to describe length of source code and I've always wondered what does this mean exactly. A good example is this coding standard that states:

Functions should limit themselves to a single page of code.

This makes sense if the code is printed on paper. But what does this mean in other contexts? The amount of code that fits on the screen at once?

Posted Dec 23, 2018, 11:13 PM UTC

78
Spfifle•

Yah they mean a single screen's worth or code. It's a pretty soft measurement for a pretty soft rule. On the spectrum from vertical monitor to stereotypical IDE user could be hundreds of lines or 4.

9
nutrecht•

This is the correct answer. It's just a soft guideline. If your method/function doesn't fit on a single screen it's generally a good indication it's too long.

2
o11c•

A page is universally defined as 80 columns wide and 24-25 lines tall. This dates back to the days of the VT52, among others.

An 8x16 bitmap font on a 640x400 screen is 80x25.

7
WebDevLikeNoOther•

I’m not sure it’s referring to the view on the screen. I believe it’s referring to Code Pages which isn’t something you should really worry about in this day and age, at least starting out. It describes the encoding type of the code, by a particular page number. The standard is UTF-16 encoding, which is used by Unicode.

In general, your methods should be as small as possible, while maintaining readability. If you can’t quickly glance at a function, and know what it does within 5-10 seconds, then it’s probably too long.

1
mtaonOP•

Thanks but I don't think that it refers to code pages. For example expression "half a page of code" is used here.

5
WebDevLikeNoOther•

I’m honestly not sure then. Because different screen sizes would change how much you’d consider a “page”. Sorry I couldn’t help!

2
nutrecht•

No that's just plain wrong. It just refers to functions being able to fit on a single screen.

2
WebDevLikeNoOther•

Like I said, I wasn’t sure but was just throwing out a guess. Screen size is pretty relative, so it’s hard to gauge what one function fitting on a screen would be, depending on the screen size of your machine.

2