KLOC is a metric that measures the size of a software project. It’s a number of lines of source code the program contains, usually in the thousands. If a software project has 20,000 lines of code, it’s 20 KLOC.
KLOC can provide some insight into the scale of a software project but it’s not enough. More metrics offer a more comprehensive understanding of software quality, complexity, and productivity.
What to consider about the KLOC metric:
- Measurement variability. The count can vary depending on how you count the lines of code. For instance, do comments and whitespace lines count? Different standards or tools might produce different KLOC counts for the same code.
- Quality vs. quantity. While KLOC can give a rough measure of the size of a project, it says nothing about the quality of the code. A smaller, well-written codebase can be more effective than a larger, poorly-written one.
- Management and estimation. In the past, KLOC was the basis for project estimation. However, relying on KLOC alone is misleading. Writing more lines of code doesn’t necessarily mean more functionality or better software.
- Modern metrics. Many modern software development practices focus more on functional deliverables rather than raw lines of code. Metrics like “story points” in Scrum, for instance, measure effort based on the complexity of user stories rather than lines of code.