Not logged in. Login

Software Metrics

Software metrics are measures that are related to software, its development and its evaluation.

  • Product metrics are measures related to the software itself, such as the number of lines of code (LOC) written.
  • Process metrics are measures related to the process of software development, testing and maintenance, such as the number of lines of code produced per week (LOC/week).

Software Metrics and Repeatable Software Process

How do you estimate the cost of developing, testing and maintaining software systems?

Metrics are needed to provide a basis for prediction of development time and cost.

  1. Apply a consistent set of software metrics throughout a development project.
  2. Use metrics from a previous project to estimate development costs for a new project.
  3. Compare estimated costs with actual costs to help refine metrics used.
  4. Use metrics to identify bottlenecks in the overall software process.
  5. Continuous software process improvement incrementally adjusts the software process to address flaws and bottlemecks revealed by software metrics.

Software Source Code Metrics

Lines of code (LOC) is probably the most commonly used metric for estimating the size of a software system.

  1. Simple to automate, programming language independent.
  2. Various Drawbacks
    1. Should you include comment lines in your code?
    2. Non-comment LOC might be a better measure of the actual code.
    3. Comment LOC/non-comment LOC might measure how well documented code is.
  3. Duplicated lines of code (DLOC) might be a metric for code bloat.

Halstead Software Volume

Identify the operators and operands of the software.

  • Let \(n_1\) = total number of unique operators in a program.
  • Let \(n_1\) = total number of unique operands in a program.
  • Let \(N_1\) = total number of occurrences of the operators.
  • Let \(N_2\) = total number of occurrences of the operands.

Software volume is then \(V = N * \log_2 n\) where \(N = N_1 + N_2\) and \(n = n_1 + n_2\).

Halstead's software volume attempts to focus on the overall size of the software logic, ignoring comments, formatting and other extraneous factors.

Halstead's volume measure can be applied to each function or file to rate the comparative logical size of each program unit.

McCabe Cyclomatic Complexiry

McCabe's complexity metric attempts to measure the overall complexity of software source code.

\(C = \) number of branches + 1

The insight underlying McCabe's measure is that the complexity of reading and analyzing software is proportional to the logical number of branches within the software.

  • A simple straight-line program may be easy to analyze even its volume is high.
  • A complex branching program may be hard to analyze even if its volume is low.
  • Defect density of software has been found to be better correlated with cyclomatic complexity than with software volume.

Software Requirements Metrics

Before a software system is written, how can you estimate the development cost?

Metrics defined over the software requirememts can be used to predict overall development cost.

Function points are a count of the number of individual units of functionality in a software system.

For example, in agile development, one possible measure of the overall size or complexity of software requirements is to count the total number of TDD examples.

Updated Sun Sept. 10 2023, 10:44 by cameron.