Halstead’s Complexity Measures

Taylor Emma
2 Min Read
Disclosure: This website may contain affiliate links, which means I may earn a commission if you click on the link and make a purchase. I only recommend products or services that I personally use and believe will add value to my readers. Your support is appreciated!

In 1977, Mr. Maurice Howard Halstead introduced metrics to measure software complexity. Halstead’s metrics depends upon the actual implementation of program and its measures, which are computed directly from the operators and operands from source code, in static manner. It allows to evaluate testing time, vocabulary, size, difficulty, errors, and efforts for C/C++/Java source code.

According to Halstead, “A computer program is an implementation of an algorithm considered to be a collection of tokens which can be classified as either operators or operands”. Halstead metrics think a program as sequence of operators and their associated operands.

He defines various indicators to check complexity of module.

ParameterMeaning
n1Number of unique operators
n2Number of unique operands
N1Number of total occurrence of operators
N2Number of total occurrence of operands

When we select source file to view its complexity details in Metric Viewer, the following result is seen in Metric Report:

MetricMeaningMathematical Representation
nVocabularyn1 + n2
NSizeN1 + N2
VVolumeLength * Log2 Vocabulary
DDifficulty(n1/2) * (N1/n2)
EEffortsDifficulty * Volume
BErrorsVolume / 3000
TTesting timeTime = Efforts / S, where S=18 seconds.

 

Share This Article
A senior editor for The Mars that left the company to join the team of SenseCentral as a news editor and content creator. An artist by nature who enjoys video games, guitars, action figures, cooking, painting, drawing and good music.
Leave a review