A number that measures a property of the software helps to judge it and to improve it. Metrics are the base of quality control.

Software Quality

Software quality is conformance to explicitly stated requirements, to stated development standards and to implicit expectations. McCall's factors group the quality attributes by the use of the software. They include correctness, reliability, efficiency, integrity and usability for operation, maintainability, flexibility and testability for change, and portability, reusability and interoperability for transfer. A measure is a single data point such as the number of errors found in a review. A metric relates measures, such as errors per review, and an indicator is a metric that gives insight into the product.

Definition: Software metric. A quantitative measure of the degree to which a software product or process has some property.

Metrics for the Analysis and Design Models

For the analysis model, function points measure size from the inputs, outputs, inquiries, files and interfaces seen by the user, with each counted and weighted. For the design model, architectural metrics such as fan-in, the number of modules that call a module, and fan-out, the number of modules called by it, show coupling. Component-level metrics measure cohesion, coupling and complexity. Class-based design uses metrics such as the number of methods in a class and the depth of the inheritance tree.

Metrics for Source Code, Testing and Maintenance

Halstead's metrics use counts of operators and operands to give the program length and volume. Cyclomatic complexity is also used for source code, and values above 10 suggest the module is hard to test. For testing, metrics include test coverage, the share of code run by the tests, and the number of defects found per test. For maintenance, the software maturity index, SMI = (Mt - (Fa + Fc + Fd)) / Mt, measures the stability of a product, where Mt is the number of modules in the current release, Fa the added, Fc the changed and Fd the deleted modules. As SMI approaches 1, the product becomes stable.

Table 3.8: Product metrics by area

Area Metric Measures
Analysis Function points Size from user functions
Design Fan-in, fan-out, cohesion Structure and coupling
Source code Halstead, cyclomatic complexity Size and complexity
Testing Coverage, defects found Thoroughness of tests
Maintenance Software maturity index Stability of releases

Example 3.8: Software maturity index

Problem: The current release has 120 modules. Compared with the last release, 6 modules were added, 10 changed and 4 deleted. Find the SMI.

Solution:

  1. Fa + Fc + Fd = 6 + 10 + 4 = 20.
  2. SMI = (120 - 20) / 120 = 100 / 120.

Result: SMI = 0.833, so the product is fairly stable and nearing a stable release.

Mt, Fa, Fc, Fd = 120, 6, 10, 4
print(round((Mt - (Fa + Fc + Fd)) / Mt, 3))
import math
n1, n2, N1, N2 = 10, 8, 40, 30
volume = (N1 + N2) * math.log2(n1 + n2)
print(round(volume, 1))

Output

0.833
291.9

Common mistakes

  • Collecting metrics but never using them to take decisions.
  • Judging a programmer by a single metric such as lines of code.
  • Comparing metrics from projects that were measured in different ways.

Key takeaways

  • A measure is a single data point, a metric relates measures.
  • Function points measure size from the user's view.
  • Fan-in and fan-out show coupling in the design.
  • SMI near 1 shows a stable product.

Practice questions

  1. What does the software maturity index measure?
  2. What is fan-out?
  3. Name two metrics for source code.

Answers to the practice questions

  1. The stability of a product from release to release.
  2. The number of modules called by a module.
  3. Halstead's metrics and cyclomatic complexity.

Sources

  • Official BCA syllabus Software Engineering, course code 26BCA403DS03, Unit III