KLOC

KLOC or thousand (K) lines of code is a simple metric used to quantify code. Unfortunately, although simple to collect, KLOC is also a poor metric and often misused.

Benefits of KLOC

 * Simple to state.

Problems with KLOC

 * Requires careful consideration to make consistent assessments.
 * Assessing code productivity using KLOC can lead to excessive code (people writing code with more lines than required to do the job in order to inflate their productivity measure).
 * It is unclear that there is any correlation between KLOC and code quality or complexity.

Defining a line of code
One problem with KLOC is defining a line of code.

if (this == that) { do something; }

Is this one line of code, two, or three? Do you count the '}' as a line of code when it stands on a line alone? If so, then what about the '{{mono|{}}', if that appears on the same line as the condition it is 'rolled into' that line, but if it is on a separate line it may be counted.

if (this == that) {    do something; }

Is this now four lines?

Mitigation strategies

 * Standardise code formatting.
 * Enforce coding standard with automated formatting tools.
 * Automate line counting using tools.