halsted’s software science-an analytical technique

19
PREPARED BY- NUR ISLAM Halsted’s Software Science- An Analytical Technique Department of Information Technology BESU, SHIBPUR 1

Upload: nur-islam

Post on 23-Jun-2015

974 views

Category:

Education


4 download

TRANSCRIPT

Page 1: Halsted’s Software Science-An analytical technique

1

PREPARED BY-

NUR ISLAM

Halsted’s Software Science-An Analytical Technique

Department of Information TechnologyBESU, SHIBPUR

Page 2: Halsted’s Software Science-An analytical technique

2

Halstead’s Software Science

Halstead’s software science is an

analytical estimation method. -Have scientific basis

Starts with few simple assumptions about the product, Halstead used few primitive program parameters to develop expressions for:

1. Overall program length 2. Potential minimum volume and Program level 3. Actual volume 4. Effort 5. Development time

Page 3: Halsted’s Software Science-An analytical technique

3

Important Keywords

Operator in general: a symbol or function representing a mathematical operation. assignments arithmetic and logical operators Parentheses pair, block begin/end pair If…then… else… endif Do…. While Statement terminator “;” Bitwise operator Pointers operator

Page 4: Halsted’s Software Science-An analytical technique

4

Important Keywords

Operands in general: A quantity to which an operator is applied– Subroutine declarations– Variable declarations– Variables and constants used with operatorsin an expression

Page 5: Halsted’s Software Science-An analytical technique

5

Example

1.a=&b

• Operands: a , b• Operators : = , &

2.

func(a, b);• Operators: func, “,” ,

“;” , “()”• Operands: a , b

3.int func (int a, int

b) {

... }

• Operators: {} , (), “,”

Page 6: Halsted’s Software Science-An analytical technique

6

Halstead’s Software Science

• For any giving programs lets define the following parameters:– η1 be the number of unique parameters used in the program

– η2 be the number of unique operands used in the program

– N1 be the number of the total parameters used in the program

– N2 be the number of the total operands used in the program

Page 7: Halsted’s Software Science-An analytical technique

7

Halstead’s Software Science

Length and Vocabulary:– Program Length (N)= N1 + N2

This notation agrees with our understanding of the total length of a program as the total count of tokens (operators and operands)

– Program Vocabulary (η)= η1 + η2

Page 8: Halsted’s Software Science-An analytical technique

8

Halstead’s Software Science

Program Volume:Program volume (V)= is the minimum number of bits

needed to encode the program– Program vocabulary and length depends on the programming style– Different lengths of programs, corresponding to the same problem when different languages are used– We need to express the program length by taking the programming language into consideration

Page 9: Halsted’s Software Science-An analytical technique

9

Halstead’s Software Science

Program volume (V)= is the minimum number of bits needed to encode the program

– Program volume V = N log2(η)

• To represent η different tokens we need log2(η) bits

– Example: to represent 8 operands we need 3 bits• For a program of N length, we need N log2(η) bits– Program volume represents the size of the program by approximately compensating the effect of the programming language used

Page 10: Halsted’s Software Science-An analytical technique

10

Halstead’s Software Science

Potential Program Volume (V*):– V* is the volume of the most concise program in which the problem can be coded– A program require at least 2 operators (η1=2) and the required number of operands is η2• Example : func()– Therefore: V* = (2+η2) log2(2+η2)– Program Level (L) = V*/V– Program level gives an indication of the language level of abstraction– Higher L , higher the language is easier to program with• Example: Assembly vs. C#

Page 11: Halsted’s Software Science-An analytical technique

11

Halstead’s Software Science

Effort and Time:– To obtain the needed effort , we divide the program volume (size) on the program level (complexity)

–Effort = E =V / L = V /V*– The programmer’s time needed to

finish the program (T) = E / S, where S is the speed of mental discriminations

• The recommended value of S is 18

2

Page 12: Halsted’s Software Science-An analytical technique

12

Halstead’s Software Science

Estimation of Length:•Although the program length can be

estimated easily using the previous discussed equation N = N1+N2, this can be done before starting the programming activities.

• Instead, we can calculate the length depending on the unique numbers of operands and operators

Page 13: Halsted’s Software Science-An analytical technique

13

Halstead’s Software Science

• Halstead assumptions are based on:– Program are unlikely to have several identical parts that are greater than (η)– Identical parts are usually made into procedures and functions– Any program of length N consists of N/ηunique strings (of length η)– for an alphabet of size K, there are K strings of length r

r

Page 14: Halsted’s Software Science-An analytical technique

14

Halstead’s Software Science

N = η1 log2 (η1) + η2log2(n2)• Experimental evidence showed that the actual and the computed values are very close• Results may be inaccurate when dealing with small programs or subsystems individually

Page 15: Halsted’s Software Science-An analytical technique

15

Recap

Unique operators : η1 Unique Operands : η2Total Operators : N1Total Operands : N2Program Vocabulary : η=η1+η2Program Length : N=N1+N2Program Volume : Nlog2ηEffort : E=V/LTime : T=E/SEstimated Length :

N=η1log2η1+η2log2η2Estimated Effort : E=V.(η1/η2).(N2/2)

Page 16: Halsted’s Software Science-An analytical technique

16

Example

Main(){

int a, b, c, avg;scanf(“%d %d %d”, &a, &b, &c);avg = (a +b +c )/3;printf(“avg = %d”, avg);

}

Page 17: Halsted’s Software Science-An analytical technique

17

Example

The unique operators are: main, (), {}, int, scanf, &, “, ”, “;”, =, +, /, printf

The unique operands are:a, b, c, &a, &b, &c, a +b +c, avg, 3, “%d %d %d”, “avg = %d”

therefore η1 = 12, η2 = 11N = 12 log2(12)+ 11log2(11)

=81V = Nlog2(η) = 81log2(23)

= 366

Page 18: Halsted’s Software Science-An analytical technique

18

Resources

• Wikipedia• Fundamentals of Software Engineering by

Rajib Mall, Chapter 3

Page 19: Halsted’s Software Science-An analytical technique

19

THANK YOU