Presentation is loading. Please wait.

Presentation is loading. Please wait.

Halstead’s software science: An analystical model

Similar presentations


Presentation on theme: "Halstead’s software science: An analystical model"— Presentation transcript:

1 Halstead’s software science: An analystical model

2 Halstead’s Software Science Source Code Metrics
Overall program length Potential minimum algorithm volume Actual algorithm volume number of bits used to specify program Program level software complexity Language level constant for given language

3 Halstead’s Software Science (entropy
measures)‏ – n1 - number of distinct operators – n2 - number of distinct operands – N1 - total number of operators – N2 - total number of operands

4 An example if (k < 2)‏ { if (k > 3)‏ x = x*k; }
• Distinct operators: if ( ) { } > < = * ; • Distinct operands: k 2 3 x • n1 = 10 • n2 = 4 • N1 = 13 • N2 = 7

5 Operators ( [ . , -> * + _ ! ~ ^ < > <= & % && ? / *= ; IF ELSE SWITCH WHILE DO FOR CONTINUE GOTO BREAK etc a = &b here a and b are operands and = & are operators Function name in a function definition not an operator Function name in a function call is an operator and arguments of the function call are operands. However, parameter list of a function in the function declaration statement is not treated as operands.

6 Halstead’s Metrics Program length: N = N1 + N2
Program vocabulary: n = n1 + n2 Estimated length: = n1 log2 n1 + n2 log2 n2 Close estimate of length for well structured programs Purity ratio: PR = /N

7 Program Complexity Volume: V = Estimated Length * log2 n
Number of bits to provide a unique designator for each of the n items in the program vocabulary. V is the minimum no. of bits needed to encode the program Difficulty Program effort: E=D*V This is a good measure of program understandability

8 Example main()‏ { int a,b,c,avg; scanf(“%d %d %d”, &a, &b, &c);
avg = (a+b+c)/3; printf(“avg = %d”, avg); } Unique operators: main, (), {}, int, scanf, &, “,”,”;”, =, +, /, printf Unique operands: a,b,c, &a, &b, &c, a+b+c, avg, 3,”%d %d %d”, “avg=%d” Therefore, n1 = 12, n2 = 11

9 Estimated length = (12 * log 12 + 11 * log 11)‏
= 81 Volume = Length * log(23) = 81 *4.52 = 366

10 Conclusion Halstead’s theory tries to provide a formal definiton and quantification of such attributes as program complexity, ease of understanding and level of abstraction based on some low-level parameters such as the number of operands and operators appearing in the program Provides gross estimates of properties of a large collection of s/w, but extends to individual cases rather inaccurately


Download ppt "Halstead’s software science: An analystical model"

Similar presentations


Ads by Google