Halstead complexity measures: Difference between revisions

Content deleted Content added
Dekart (talk | contribs)
Dekart (talk | contribs)
mNo edit summary
Line 1:
'''Halstead complexity metricmeasures''' is aare [[software metric]]s indroduced by Maurice Howard Halstead in 1977. ThisThese metricmetrics isare computed statically, without program execution.
 
== Calculation ==
Line 7:
* <math>N1</math> = the total number of operators
* <math>N2</math> = the total number of operands
 
From these numbers, five measures can be calculated:
* Program length: <math>N = N1 + N2 \,</math>
* Program vocabulary: <math>n = n1 + n2 \,</math>
* Volume: <math>V= N \times \log_2 n \,</math>
* Difficulty : <math>D= { n_1 \over 2 } \times { N_2 \over n_2 } \,</math>
* Effort: <math>E= D * V \,</math>
 
WhereThe Ddifficulty =measure is related to the difficulty of the program to write or understand, e.g. when doing [[code review]].
 
* Number of the used different operators ((<math>n_1</math>) and operand (<math>n_2</math>), ), together the vocabulary size <math>n</math>.
* Number of the altogether used operators (<math>N_1</math>) and operand (<math>N_2</math>), together the implementation length <math>N</math>.
 
From this then the sizes of Halstead length become (<math>HL</math>) and Healstead volume (<math>HV=V</math>) are calculated:
* <math>HL = n_1 \times \log_2 n_1 + n_2 \times \log_2 n_2</math>
* <math>HV = N \times \log_2 n</math>
 
From the base quantities one can compute different characteristic numbers, e.g.:
* <math>D = { n_1 \over 2 } \times { N_2 \over n_2 }</math>
Where D = difficulty of the program to write or understand, e.g. when doing [[code review]].
 
== See also ==