16
Halstead Software Science Sunil Kumar Indranil Nandy 06IT6012 & 06CS6010

Halstead's Software Sc (by Indranil Nandy)

Embed Size (px)

DESCRIPTION

A discussion about Halstead's Software Science

Citation preview

Page 1: Halstead's Software Sc (by Indranil Nandy)

Halstead Software Science

Sunil Kumar Indranil Nandy 06IT6012 & 06CS6010

Page 2: Halstead's Software Sc (by Indranil Nandy)

Guidelines for C:- Comments are not considered. Identifier and function declarations are not

considered.As an example, func(a,b);-----here func, a and b

are considered operands and ‘,’ and ‘;’ operators as it is calling a function, but for the following case we do not treat func, a and b as operands

int func(int a , int b) {…….…….

}

Hash directives are considered.

Page 3: Halstead's Software Sc (by Indranil Nandy)

Operators:- Function calls. All looping statements like for(),

while() etc.

All control statements like if(), if()-else etc.

Control construct switch ().

Page 4: Halstead's Software Sc (by Indranil Nandy)

Keywords words. Brackets, commas and terminator. Goto. All operators like arithmetic, logical etc. ‘.’ and ‘->’.

Page 5: Halstead's Software Sc (by Indranil Nandy)

Operands:-

All variables and constants.

Local variables with same names in different functions are considered as unique operands.

Labels.

Page 6: Halstead's Software Sc (by Indranil Nandy)

Array name is counted as operands. Structure-name, member-name Same names of member element

in different structure variable are considered as unique operands.

Page 7: Halstead's Software Sc (by Indranil Nandy)

Guidelines for C++ and JAVA:- All C guidelines are also considered.

:: operator.

Class object and member elements are considered as operands.

Call to member function by class object is considered as operator.

Page 8: Halstead's Software Sc (by Indranil Nandy)

Default parameter assignments are not counted, e.g.,

class Point {Point(int x = 0,int y = 0);

};------------ is not counted.

new and delete considered same as the function calls, mainly because they are equivalent to the function calls.

There are two extra operators in JAVA : >>> and >>>+ -------each is considered a single operator.

Page 9: Halstead's Software Sc (by Indranil Nandy)

Explicit List of Operands & Operators

In C :Operands :

Tokens of the following categories are all counted as operands :

IDENTIFIER : all identifiers that are not reserved words

TYPENAME (type specifiers) : Reserved words that specify type: int, float, char, double, long, short, signed, unsigned, void. This class also includes some compiler specific nonstandard keywords.

CONSTANT : Character, numeric or string constants.

Page 10: Halstead's Software Sc (by Indranil Nandy)

Operators :Tokens of the following categories are all counted

as operators : SCSPEC (storage class specifiers) : Reserved words that

specify storage class: auto, extern, register, static, typedef..

TYPE_QUAL (type qualifiers) : Reserved words that qualify type: const, final, volatile.

RESERVED Other reserved words of C: break, case, continue, default, do, if, else, enum, for, goto, if, new, return, sizeof, struct, switch, union, while. This class also includes some compiler specific nonstandard keywords.

OPERATOR : !   !=   %   %=   &   &&   ||   &=   ( ) { } [ ] *   *=   +   ++   +=   ,   -   --   - =   - > .    /   /=   :   ::   <   <<   <<=   <=   =   ==   >   >=   >>   >>=   ?     ^   ^=   |   |=   ~ ; =& “ “ ‘ ‘ # ##

Page 11: Halstead's Software Sc (by Indranil Nandy)

Operators in C++ & JAVA Operands are more or less same in C++ and JAVA as in C. So

we are specifying only the operands list in C++ and JAVA. Tokens of the following categories are all counted as operators :

SCSPEC (storage class specifiers) Reserved words that specify storage class: auto, extern, register, static, typedef, virtual, mutable, inline.

TYPE_QUAL (type qualifiers) Reserved words that qualify type: const, friend, volatile, final.

RESERVED Other reserved words of C++ & JAVA: break, case, continue, default, do, if, else, enum, for, goto, if, new, return, asm, operator, private, protected, public, sizeof, struct, switch, union, while, this, namespace, using, try, catch, throw, abstract, concrete, const_cast, static_cast, dynamic_cast, reinterpret_cast, typeid, template, explicit, true, false. This class also includes some compiler specific nonstandard keywords

OPERATOR !   !=   %   %=   &   &&   ||   &=   ( )  { } [ ] *   *=   +   ++   +=   ,   -   --   - =   -> . /   /=   :   ::   <   <<   <<=   <=   =   ==   >   >=   >>   >>=   ?     ^   ^=   |   |=   ~ ; =& “ “ ‘ ‘ # ## ~

Page 12: Halstead's Software Sc (by Indranil Nandy)

/* Program calculating addition or Subtraction of two integers */

#include <stdio.h>int add(int, int);int sub(int, int);void main(){

int a, b, result;printf(“Enter First no : ”);scanf(“%d”, &a);printf(“Enter Second no : ”);scanf(“%d”, &b);if(a>b)

result=sub(a,b);else

result=add(a,b);printf(“RESULT = %d”,result);

}

Page 13: Halstead's Software Sc (by Indranil Nandy)

int sub(int c, int d){

int e;e=c-d;return(e);

}

int add(int c, int d){

int e;e=c+d;return(e);

}

Page 14: Halstead's Software Sc (by Indranil Nandy)

Operator Occurrence Operands Occurrence

main 1 Main function{} 3 a 4

printf 3 b 4

scanf 2 result 3

if-else 1

> 1 Add function

= 4 c 1

add 1 d 1

sub 1 e 2

+ 1

- 1 Sub function

return 2 c 1

; 11 d 1

, 2 e 2

η1= 14 N1=34 η2= 9 N2=19

Page 15: Halstead's Software Sc (by Indranil Nandy)

N (program length) = N1+N2

= 34+19= 53

Nh (Halstead estimated length) = η1 log2 η1 + η2 log2 η2= 14 log2 14 + 9 log2 9=81.8

Ns (shooman estimated length)= (η1+η2)[0.5772 + ln(η1+η2)] = (14+9)[0.5772 +

ln(14+9)]= 85.4

Page 16: Halstead's Software Sc (by Indranil Nandy)

Thank you……….