Halstead software science measures and other metrics for

  • Slides: 9
Download presentation
Halstead software science measures and other metrics for source code V. KUBERA SAMRAT

Halstead software science measures and other metrics for source code V. KUBERA SAMRAT

Why ? Drawbacks in LOC It is programming language dependent. Poor software design may

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

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

Halstead metric M. H. Halstead proposed this metric Using primitive measures Derived once the design phase is complete and code is generated. The measures are: n 1= number of distinct operators in a program n 2= number of distinct operands in a program N 1= total numbers of operators N 2= total number of operands By using these measures, Halstead developed an expression for overall program length, program volume, program difficulty, development effort

Contd. , Program length (N) can be calculated by using equation: N = n

Contd. , Program length (N) can be calculated by using equation: N = n 1 log 2 n 1 + n 2 log 2 n 2 Program volume (V) can be calculated by using equation: V = N log 2(n 1+n 2) Volume ratio (L) can be calculated by using the following equation: L=(Volume of most compact program)/(volume of actual program) L = (2/n 1 )* (n 2/N 2 ) Program difficulty level (D) and effort(E) can be calculated by equations: D = (n 1/2)*(N 2/n 2) E=D*V

General Counting rules for C-Program Comments are not considered The identifiers and function declarations

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.

Contd. , Function calls are considered as operators. All looping statements and all control

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

Mc. Cabe's Cyclomatic Complexity V(G) It is logical metrics for source code. Uses a

Mc. Cabe's Cyclomatic Complexity V(G) It is logical metrics for source code. Uses a Program Control Graph Basis for Mc. Cabe'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

Information flow metrics This metric was first proposed by Katura and Henry It is

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.