halsted’s software science-an analytical technique

Post on 23-Jun-2015

974 Views

Category:

Education

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

PREPARED BY-

NUR ISLAM

Halsted’s Software Science-An Analytical Technique

Department of Information TechnologyBESU, SHIBPUR

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

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

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

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: {} , (), “,”

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

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

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

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

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#

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

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

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

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

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)

16

Example

Main(){

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

}

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

18

Resources

• Wikipedia• Fundamentals of Software Engineering by

Rajib Mall, Chapter 3

19

THANK YOU

top related