Halstead’s Theory Metrics in Software Engineering

Halstead’s theory is an analytical estimation technique to measure the size, development effort, and development cost of software products. Halstead’s used a few primitive program parameters to develop the expressions for overall program length, potential minimum volume, actual volume, effort & development time.

  • In Halstead software science the function name in a function call statement is also considered an operator and the arguments of the function call are called operands.
  • Operands are those variables and constants which are used with the operators in expressions.
  • In Halstead’s theory following is the list of operators used:
Function name in a function call, return, break, continue, goto, for, do, while, switch, else, default if, case, ;, {}, ?, :, ^=, &=, >>=, <<=, -=, +=, %=, /=, *=, &&, ||, ^, &, ==, <=, >=, >, <, <<, >>, -, +, %, /, *, --, ++, !, *, ,, ., [], (), ≠, ∼, -->, |=.

The metrics of Halstead’s theory are as:

  • η1: no. of unique operations used in the program
  • η2: no. of unique operands used in the program
  • N1: Total no. of operators used in the program
  • N2: Total no. of operands used in the program
  • For Example: If Y= (a+b) * (C+d)*(d+e) then η1=3, η2=6, N1=6, N2=7
  • Length & Vocabulary:
    • The length of a program quantifies the total usage of all operators & operands in the program. Thus, Program Length,N = N1 + N2
    • The Program Vocabulary is the no. of unique operators & operands used in the program. Thus, Program Vocabulary, η = η1+ η2
  • Program Volume: The length of the program depends on the choice of operator and operands used. So, V = N^ log 2 η
    • where V is volume: minimum no. of bits required to encode the program.
    • i.e. V bits needed to store a program of length N.
  • Potential minimum volume: It is defined as the volume of the most limited program in which it can be encoded. So, V * = ( 2 + η2 ) log 2 ( 2 + η2 )
  • Program level is given by: L = V * / V
    • It is an attempt to measure the level of abstraction provided by the programming language.
    • Higher the level of a language the less effort it takes to develop a program in that language.
  • Effort : E = V/L
    • Where E is the no. of mental discrimination required to implement the program & the effort required to read & understand the program E = V/ L = V2/ V*
  • Programming Time : T = E/ S
    • Where S is the speed of mental discrimination known as stroud number. For software, it is taken as 18.
  • Length Estimation: Halstead determines the length of the program using no. of unique operators & operands used in the program.
    • N^ = log η1η1 + log η2η2 = η1 log η1 + η2 log η2

” Halstead theory tries to provide a formal definition & qualification of such qualitative, empirical & subjective quantities as program complexity, ease of understanding & level of abstraction based on some low-level quantities such as no. of operands & operators appearing the Program.”

Halstead Theory Metrics Example

Example 1: Consider the following C program

main ()
{
int a,b,c, avg;
scanf(%d %d %d", &a, &b, &c);
avg = (a+b+c)/3;
printf("avg = %d", avg);

Calculate the estimated length and program volume.

Solution 1: η1 = 12

main, (), {, int, scanf, &, ,, ;, =, +, /, printf

η2 = 11

a, b, c, avg, &a, &b, &c, a+b+c, 3, %d%d%d, avg=%d

N = 12 log 2 12 + 11 log 2 11 = 81

V = N log 2 η = 81 log 2 23 = 366

η = 12+ 11 = 23


Discover more from easytechnotes

Subscribe to get the latest posts sent to your email.

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top