0% found this document useful (0 votes)
160 views9 pages

Halstead Software Science

The document discusses various software metrics for measuring source code complexity, including Halstead metrics, McCabe's cyclomatic complexity, and information flow metrics. Halstead metrics are based on counting operators and operands, and can measure the program length, volume, difficulty, and development effort. McCabe's metric uses a program control graph to measure complexity as the number of paths through the code. Information flow metrics consider the length, number of calls to (fan-in) and from (fan-out) a module to determine its complexity.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views9 pages

Halstead Software Science

The document discusses various software metrics for measuring source code complexity, including Halstead metrics, McCabe's cyclomatic complexity, and information flow metrics. Halstead metrics are based on counting operators and operands, and can measure the program length, volume, difficulty, and development effort. McCabe's metric uses a program control graph to measure complexity as the number of paths through the code. Information flow metrics consider the length, number of calls to (fan-in) and from (fan-out) a module to determine its complexity.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 9

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

The measures are:


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 = n1log2 n1 + n2log2 n2 V = N log2(n1+n2)

Program volume (V) can be calculated by using equation:

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

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

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

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

You might also like