Halstead complexity measures
Encyclopedia
Halstead complexity measures are software metric
Software metric
A software metric is a measure of some property of a piece of software or its specifications. Since quantitative measurements are essential in all sciences, there is a continuous effort by computer science practitioners and theoreticians to bring similar approaches to software development...

s introduced by Maurice Howard Halstead in 1977 as part of his treatise on establishing an empirical science of software development.
Halstead makes the observation that metrics of the software should reflect the implementation or expression of algorithms in different languages, but be independent of their execution on a specific platform.
These metrics are therefore computed statically from the code.

Halstead's goal was to identify measurable properties of software, and the relations between them.
This is similar to the identification of measurable properties of matter (like the volume, mass, and pressure of a gas) and the relationships between them (such as the gas equation
Ideal gas law
The ideal gas law is the equation of state of a hypothetical ideal gas. It is a good approximation to the behavior of many gases under many conditions, although it has several limitations. It was first stated by Émile Clapeyron in 1834 as a combination of Boyle's law and Charles's law...

).
Thus his metrics are actually not just complexity metrics.

Calculation

First we need to compute the following numbers, given the program:
  • = the number of distinct operators
  • = the number of distinct operands
  • = the total number of operators
  • = the total number of operands


From these numbers, several measures can be calculated:
  • Program vocabulary:
  • Program length:
  • Calculated program length:
  • Volume:
  • Difficulty :
  • Effort:


The difficulty measure is related to the difficulty of the program to write or understand, e.g. when doing code review
Code review
Code review is systematic examination of computer source code. It is intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers' skills...

.

The effort measure translates into actual coding time using the following relation,
  • Time required to program: seconds

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK