Subject: Time to update KNF?
To: None <tech-kern@netbsd.org>
From: Mike Cheponis <mac@Wireless.Com>
List: tech-kern
Date: 01/17/2000 15:58:31
KNF specifies tab-delineated indentation, viz.
for (; cnt < 15; cnt++) {
stmt1;
stmt2;
}
Also:
/* Second level indents are four spaces. */
while (cnt < 20)
z = a + really + long + statement + that + needs + two +
lines + gets + indented + four + spaces + on + the +
second + and + subsequent + lines;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
However, Richard J. Miaria, et al 1983 "Program Indentation and
Comprehensibility" Communications of the ACM 16, no 11 (Nov) 861-67
reports on several studies that found correlations between indentation and
improved comprehension.
This from Code Complete, Steve McConnel, Microsoft Press, pp 409-401:
"Subjects scored 20 to 30 percent higher on a test of comprehension when
programs had a two-to-four-spaces indentation scheme than they did when
programs had no indentation at all.
"The same study found that it was important to neither under-emphasize nor
over-emphasize a program's logical structure. The lowest comprehension
scores were achieved on programs that were not indented at all. The second
lowest were achieved on programs that used six-space indentation.
"The study concluded that two-to-four-space indentation was optimal.
"Interestingly, many subjects in the experiment felt that the six-space
indentation was easier to use than the smaller indentations, even though
their scores were lower. That's probably because six-space indentation
looks pleasing. But regardless of how pretty it looks, six-space
indentation turns out to be less readable. This is an example of a
collision between aesthetic appeal and readability."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Therefore, I propose that we change KNF immediately to use two spaces for
indents, since two-to-four are optimal, might as well choose two.
I also propose that second level indents also be two spaces.
----------
Some may suggest that tab stop be put every 2 characters in the editor,
but 8 character tabs are standard so this causes more problems than it's
worth.
It's simplest to keep the indent at two characters.
-Mike Cheponis