Jump to content

Line of code

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 145.97.223.187 (talk) at 14:25, 21 December 2004 (disagree). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The definition of a line of code, though basic to many Software Engineering metrics, is ambiguous. What a "line of code" means will certainly vary across languages, but it also varies for a given language. But when using a standard layout, much of this ambiguousness goes away. Also comments are not code.

In the C language, for example, a line of code might be (1) a statement terminated by a newline, (2) a statement terminated by a semicolon, or (3) any line in the program terminated by a newline (comments included).

for (i=0; i<100; ++i) {printf("hello");} /* How many lines of code is this? */

Keeping these limitations in mind, the KLOC (thousand lines of code) is sometimes used as a unit for measuring a program's size or complexity. Defects per KLOC is sometimes used when measuring a program's quality.

See also