You are on page 1of 5

Software Metrics:

 Metrics and Measurements are necessary features of software development project.


They are needed to control the development process and quality of a product. To
monitor effectively on the process management needs to get information about the
project such as:

 How far it has progressed?

 How much development has taken place?

 How far behind schedule it is?

 What is the degree of the present quality of the product?

Based on these information, decision can be made about the project.

 Measure: A measure provides quantitative indication of attributes such as amount,


capacity, size etc. E.g. No. of errors found in a module during testing.

 Measurement: Act of determining a measure.

 Metric: quantitative measure of the degree to which a system or a process holds a


given attribute. E.g. Average no of errors found per hour of testing.

Measure may be direct or indirect. Direct measures are line of code produced, no of defects
found, execution speed , memory size etc. Indirect measures may be complexity, efficiency,
reliability, maintainability etc.

Definition: The continuous application of measurement based techniques to the software


development process and its products to supply meaningful and timely management
information together with the use of those techniques to improve that process and its
products.

Categories of Metrics:
 There are three categories of software metrics which are given below:

 i) Product metrics : described the characteristic of the product such as size,


complexity, design features, performance, efficiency, reliability etc.

 ii) Process metrics: described the effectiveness and quality of the processes that are
produce the software product such as :

 effort required in the process

 Time to produce the product

 Effectiveness of defect removal during development


 Number of defects found during testing

 iii) Project metrics : describe the project characteristics and execution such as

 number of software developers

 Staffing pattern over the life cycle of the software

 cost and schedule and Productivity

Areas of Applications:
• The most established area of software metrics is cost and size estimation
techniques.

• The prediction of quality levels for software, often in terms of reliability, is


another area where software metrics have an important role to play.

• The use of software metrics to provide quantitative checks on software


design is also a well established area.

• to provide management information about productivity, quality and process


effectiveness

Halstead's Complexity Measures


• In 1977, Mr. Maurice Howard Halstead introduced metrics to measure software
complexity.

• According to Halstead, “A computer program is considered to be a collection of


tokens which can be classified as either operators or operands”. Halstead metrics
think a program as sequence of operators and their associated operands.

He defines various indicators to check complexity of module

Parameter Meaning

n1 Number of unique operators

n2 Number of unique operands

N1 Number of total occurrence of operators

N2 Number of total occurrence of operands


Metric Meaning Mathematical Representation

n Vocabulary n1 + n2

N Program length N1 + N2

V Volume of program Length * Log2n

D Difficulty (n1/2) * (N1/n2)

E Efforts Difficulty * Volume

T Testing time Time = Efforts / S, where S=18 seconds.

Estimated Length n1logn1+n2log n2

PR Purity Ratio Estimated Length /N

Counting rules for C Language


1. Comments are not considered
2. The identifier and functions declarations are not considered
3. All variables and constants are considered operands,
4. Global variables used in different modules of the same program are counted as
multiple occurrences of the same variable.
5. Local variables with the same name in different functions are counted as unique
operands
6. Function calls are considered as operators.
7. All looping states and control statements are considered as operators
8. In control construct switch as well as all the case statements are considered as
operators.
9. The reserve words are considered as operators.
10. All the brackets, commas, and terminators are considered as operators.
11. GOTO is counted as an operator and the label is counted as an operand
12. The unary and binary occurrence of “+” and “-” are dealt separately, Similarly “*”
(multiplication and dereferencing operator), “&” (bitwise AND and address operator)
are dealt with separately.
13. In the array variables such as “array-name [index] “array-name” and ”index” are
considered as operands and [] is considered as operator.
14. In the structure variables such as struct-name, member –name are taken as operands .
And -> are taken as operators. Same names of member elements in different
structure variable are counted as unique operands.
15. All the hash directive are ignored.

Example: Let code is int f=1, n=7; for (int i=1; i<=n; i+=1) f*=i;

Operators Count Operands Count

int 2 f 2

= 3 1 3

, 1 n 2

; 4 7 1

for 1 i 4

() 1 -

<= 1 -

+= 1 -

*= 1 -

9 15 5 12

Halstead’s Software Metrics


N, the length of the program to be N1+N2 = ?

V, the volume of the program, to be N × log2n = ?

• Program Length (N) = N1+N2 = ?


• Estimated Program length N^= n1 log2 n1 + n2 log2 n2 =?
• Program volume (V) = N * log2n =
• Program Difficulty (D) = n1 /2 * N2 / n2 = ?
• Programming Effort (E) = V/L = D*V = ?
• Time (T’) = E/18 = ?
1. int sort(int x[],int n)
2. {
3. int i,j,temp,k;
4. /* this function sorts array x in ascending order*/
5. if(n<2)return 1;
6. for(i=2;i<=4;i++)
7. {
8. k=i-1;
9. for(j=1;j<=k;j++)
10. if(x[i]<x[j])
11. {
12. temp=x[i];
13. x[i]=x[j];
14. X[j]=temp;
15. }
16. }
17. return 0;
18. }

You might also like