Size-Oriented Metrics
What are LOC Metrics?
Lines of Code (LOC) is one of the earliest and simplest metrics used to measure the size of a computer program. It is especially useful for evaluating and comparing programmer productivity by correlating the size of the software with effort and quality.
Key Points about LOC Measures:
- LOC is the primary normalization factor in size-oriented metrics.
- It originated during the era of languages like FORTRAN and COBOL.
- Productivity is calculated as:
Productivity = KLOC / Effort
(Effort is measured in person-months)
- The metric is language-dependent — fewer lines may be needed in high-level languages.
- Assembly language may appear more "productive" due to higher LOC per task.
- LOC requires detailed code-level information, which may not be feasible in early stages of development.
- Expressive languages (like Python) may reduce LOC, but that doesn't imply reduced productivity.
- Not suitable for GUI-based projects, which rely more on visual elements than code.
- Standardization is necessary — some organizations count only executable statements, others include comments.
- Not universally accepted due to inconsistency and limitations.
Derived Metrics from LOC/KLOC:
- Errors/KLOC
- Cost/KLOC ($/KLOC)
- Defects/KLOC
- Documentation Pages/KLOC
- Errors per Person-Month
- Productivity = KLOC / Person-Month
- Cost per Documentation Page
Advantages of LOC:
- Easy to calculate
- Provides a quick estimate of code volume
Disadvantages of LOC:
- Only measures length, not functionality or complexity
- Doesn't apply to non-code artifacts like specifications or GUIs
- Can encourage poor design to increase LOC
- Highly language-specific
- Difficult for non-technical stakeholders to interpret