Halstead Complexity Measures
Halstead Complexity Measures
Halstead complexity metrics were developed by the late Maurice Halstead as a means of
determining a quantitative measure of complexity directly from the operators and operands in the
module to measure a program module's complexity directly from source code. Among the
earliest software metrics, they are strong indicators of code complexity. Halstead Science is an
estimation technique to find out size, time and effort of software.
The difficulty level or error proneness (D) of the program is proportional to the number of
unique operators in the program.
D is also proportional to the ration between the total number of operands and the number of
unique operands (i.e. if the same operands are used many times in the program, it is more prone
to errors).
D = ( n1 / 2 ) * ( N2 / n2 )
the
program.
Potential Volume:
Amongst all the programs, the one that has minimal size is said to have the potential volume, V*.
Halstead argued that the minimal implementation of any algorithm was through a reference to a
procedure that had been previously written. The implementation of this algorithm would then
require nothing more than invoking the procedure and supplying the operands for its inputs and
output parameters.
V*= (2+n2*) log2( 2+n2*)
Effort:
Halstead hypothesized that the effort required to implement a program increases as the size of
the program increases. It takes more effort to implement a program at a lower level than the
higher level.
E= V/L^