0% found this document useful (0 votes)
10 views

Question One

Halstead's software metrics measure various attributes of a program based on counting the number of unique operators and operands in the source code. The key measures include program volume (V), which represents the program size based on the number of tokens, effort (E) required to develop the program, and difficulty (D). These measures are calculated based on counting unique operators and operands to determine the program's vocabulary size (n) and length (N).

Uploaded by

Nasis Dereje
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Question One

Halstead's software metrics measure various attributes of a program based on counting the number of unique operators and operands in the source code. The key measures include program volume (V), which represents the program size based on the number of tokens, effort (E) required to develop the program, and difficulty (D). These measures are calculated based on counting unique operators and operands to determine the program's vocabulary size (n) and length (N).

Uploaded by

Nasis Dereje
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

For example:

if (k< 2) { k=3; x=x*k; }

Halstead’s software science metrics


According to Halstead’s software metrics, a program is the implementation
of an algorithm. These steps are considered as a number of tokens, and
tokens are classified as operators and operands. All software science
measures are functions of the counts of these tokens.
Token count
1. Operator –Any symbol or keyword in a program that specifies an
algorithm is considered an operator. For example, arithmetic symbols like
(+. -. /,*), punctuation marks, common names (while, for, print f), special
symbols (=, :) and function names.
2.Operand– In an algorithm or program, a symbol is used to represent
data, constants, variables, labels, etc. is considered as an operand.
• Maurice Howard Halstead brought Halstead's software metrics concept in 1977 to
measure the software metrics. Halstead's complexity measure is used to measure
program module complexity directly from source code.
• Two necessary measures of Halstead's software science are:
• Size of vocabulary ղ ( known as Ita)
• The size of the vocabulary of a program is defined as a number of unique tokens in a
program used to build a program.
• ղ =ղ1 + ղ2
• where,
• ղ = number of vocabulary in a program
• ղ1 = number of unique operators
• ղ2 = number of unique operands
• By using this formula, we can find the total number of vocabulary in a given source
code.
• Length of program N
• The total number of tokens in a program is termed as the Length of the program.
• N = N 1 + N2
• Where,
• N = Length of program
• N1= Total occurrences of operators
• N2 = Total occurrences of operators
• Additional metrics are defined using these basic terms- the size of vocabulary and Length of
the program. Another measure for the size of the program is known as:
• Program Volume (V)
• V= N x log2ղ
• Program volume is proportional to program size, represents the size of space necessary for
sorting a program.
• Unit of volume = Common unit of size “bits” {it is the actual size of the program if a uniform
binary encoding for the vocabulary is used}
• Potential Volume
• V* = represents a program having a minimal size.
• V* = (2+n2 *) log2(2+n2*)
• Program Level
• L = V* / V
• Program level L = Ranges between 0 to 1
• L =1 states that the program is written with minimum size.
• Else if L=0 states program has a maximum size.
• V* = potential volume {different or equivalent programs may implement an algorithm. Therefore program that is
minimal in size will have potential volume}
• Other different measures are:-
• Program difficulty D
• D = ղ1/2 x N2 / ղ2
• D = 1/L
• Difficulty measure is the difficulty of the program to read or write the program. If the program level decreases,
difficulty to handle that program increases.
• Effort –The amount of effort needed to translate an algorithm into implementation is specified programming
language.
• E = V/L = D x V
• V = Volume of program
• L = Level of program
• D =Program difficulty
• V= Volume of program
• Language Level λ
• λ = L* V* { L= V*/ V =>V*= LV}
• λ = L2 * V
• Time required to program
• T = E/ 18 sec
• T = Time
• E = Effort
• Number of delivered bugs
• B = E2/3/3000 {actually whole state delivered bugs is an estimated number of errors in the
implementation}
• Recently V/3000 is accepted for delivered bugs B.
• Estimated program Length
• The first hypothesis of software science is that the length of well structure software program
is a function of number of unique operators and operands.
• N =ղ1log2ղ1+ ղ2log2ղ2
• ղ1 = number of unique operators
• ղ2 = number of unique operands
• Purity Ratio
• P= N/N
• Rules for finding the number of tokens in the C programming language
• Comments, a function declared, identifier, and heading are not counted as tokens.
• All the variables, constants, labels, and variable data are considered as operands.
• The same variable used in the different functions is counted as a unique operator.
• All looping statements, switch statements, case statements are considered as operators.
• All the reserve words (default, sizeof, break, default, continue, return) and bracket,
terminator, or commas are counted as a token(operators).
• GOTO statement is the operator.
• “Array name” and index are operands.
• Hash derivatives are ignored.
• Find the number of tokens using Halstead's metrics and find n, N, V, E, λ?

You might also like