View
222
Download
0
Category
Preview:
Citation preview
measure18 1
Software Measurement
Halstead’s Software Science
measure18 2
Maurice Halstead
Originally a meteorologist– Involved in first cloud seeding
In 1970’s he did empirical studies looking for relationships between code and the “ilities” – maintainability, readability, testability, etc
Wanted to find the intrinsic things to measure
measure18 3
Vs Physics
Study blue metal balls vs white tennis balls.Conclude that blue balls made bigger dents than white balls.
measure18 4
Halstead's software science
every token is either an operator or an operand
tokens with a value are operands 2 is the number of unique operands
other tokens are operators 1 is the number of unique operators
is the total number of unique tokens = 1 + 2
measure18 5
Sample Program
Z = 0; while X > 0
Z = Z + Y ;
X = X - 1 ;
end-while ; print (Z) ;
measure18 6
Counts
= 3 ; 5 while-endwhile 1 > 1 + 1 - 1 print 1 () 1
Z 4 0 2 X 3 Y 1 1 1
measure18 7
Counting Rules
Halstead also was concerned about algorithms and not about declarations, i/o statements, etc.
Thus, he did not count declarations, input or output statements, or comments.
measure18 8
Counting Rules
There is a lot of debate about counting rules. In fact there was a conference that dealt just with counting rules. One conclusion, the results are not very sensitive to the counting rules. Pick a set of rules and be consistent.
Suggest syntax-oriented counting rules
measure18 9
Counting Rules
if two symbols always occur together, count them as one operator.
if there are two different structures that are semantically the same, still count them as two different operators.
count declarations, i/o, etc. Count everything that is necessary for expressing the program.
operators are basically keywords. user-defined items are basically operands.
measure18 10
Length, N
N = N1 + N2
where, N1 is the total number of operators and N2 is the total number of operands
measure18 11
estimate of the length, est N
If N and est N are not within 30% of each other, it is not reasonable to apply any of the other software science measures.
estN 1 1 2 2log log
measure18 12
TTYP1 - Calculate Halstead’s
cin >> a >> b >> c;if (a > b){ cout << “hello”;
if (c < a){cout << “part 1”;if ( c > b){cout << “part 2”;
}}
else{ cout << “part 3”;}}else{if (c<a){cout<<”part 4”;}
}cout << “exiting”;
Recommended