Presentation is loading. Please wait.

Presentation is loading. Please wait.

Halstead software science measures and other metrics for source code

Similar presentations


Presentation on theme: "Halstead software science measures and other metrics for source code"— Presentation transcript:

1 Halstead software science measures and other metrics for source code
V. Kubera Samrat

2 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.

3 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.,

4 Halstead metric M.H. Halstead proposed this metric The measures are:
Using primitive measures Derived once the design phase is complete and code is generated. The measures are: 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 By using these measures, Halstead developed an expression for overall program length, program volume, program difficulty, development effort

5 Contd., Program length (N) can be calculated by using equation:
N = n1log2 n1 + n2log2 n2 Program volume (V) can be calculated by using equation: V = N log2(n1+n2) Volume ratio (L) can be calculated by using the following equation: L=(Volume of most compact program)/(volume of actual program) L = (2/n1 )* (n2/N2 ) Program difficulty level (D) and effort(E) can be calculated by equations: D = (n1/2)*(N2/n2) E = D * V

6 General Counting rules for C-Program
Comments are not considered The identifiers and function declarations are not 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.

7 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], array-name and index are treated as operands and [ ] is treated as operator and so on………………..,

8 McCabe's Cyclomatic Complexity V(G)
It is logical metrics for source code. Uses a Program Control Graph Basis for McCabe's metric Measure of complexity is number of different paths through the program control graph Number of basic paths (all paths composed of basic paths) Cyclomatic Number is the number of basic paths. V(G) = Cyclomatic Complexity = edges - nodes + connected parts/no of exits

9 Information flow metrics
This metric was first proposed by Katura and Henry It is logical metric used to find the complexity of software module. The complexity in information flow metric is determined by : C = (Procedure Length) * (Fan-In * Fan-Out) (Fan-In * Fan-Out) Where, C – The complexity of the module Procedure Length – The length of the module, given in LOC or by using Mccabe’s cyclomatic complexity. Fan-In – The number of calls to the module Fan-Out – The number of calls from the module.


Download ppt "Halstead software science measures and other metrics for source code"

Similar presentations


Ads by Google