Halstead Software Science
Halstead Software Science
V. KUBERA SAMRAT
Why ?
Drawbacks in LOC It is programming language dependent. Poor software design may lead to excessive and unnecessary line of code. It treats all the lines alike.
Token
It is defined as either operator or operand in the
program.
Generally any symbol or keyword in a program that specifies algorithmic action is called an operator. eg: +/-*,while A symbol used to represent data are called as operands. eg: variables, constants, labels etc.,
Halstead metric
M.H. Halstead proposed this metric
Using primitive measures Derived once the design phase is complete and code is generated. n1= number of distinct operators in a program n2= number of distinct operands in a program N1= total numbers of operators N2= total number of operands
expression for overall program length, program volume, program difficulty, development effort
Contd.,
Program length (N) can be calculated by using equation:
equation:
calculated by equations:
D = (n1/2)*(N2/n2) E=D*V
considered All the Hash directives are ignored. All the variables and constants are considered as operands. Global variables used in different modules are considered as multiple occurrences of same variable Local variables in different functions are considered as unique operands.
Contd.,
Function calls are considered as operators. All looping statements and all control statements are
considered as operators. In control construct switch, both switch and cases are considered as operators. The reserve words like return, default etc., are considered as operators All the braces, commas and terminators are operators GOTO is counted as operator and label is treated as operand In the array variables such as array-name[index], arrayname and index are treated as operands and [ ] is treated as operator and so on..,
Measure of complexity is number of different paths through the program control graph Number of basic paths (all paths composed of basic paths)
module. The complexity in information flow metric is determined by : C = (Procedure Length) * (Fan-In * Fan-Out) (Fan-In * FanOut) Where, C The complexity of the module Procedure Length The length of the module, given in LOC or by using Mccabes cyclomatic complexity. Fan-In The number of calls to the module Fan-Out The number of calls from the module.