Software Metrics

49
Ehsan hessami Islamic Azad University OF Qazvin Software Metrics

Transcript of Software Metrics

Page 1: Software Metrics

Ehsan hessami

Islamic Azad University OF Qazvin

Software Metrics

Page 2: Software Metrics

Software measurement is the mapping of symbols to objects

What?

Page 3: Software Metrics

Software measurement is the mapping of symbols to objects

What?

quantify some attribute of the objects

Why!!!!!? !

Page 4: Software Metrics

Criteria

Page 5: Software Metrics

Criteria

A metric must allow different entities to be distinguished.

A metric must obey a representation condition

Page 6: Software Metrics

Criteria…

Each unit of the attribute must contribute an equivalent amount to the metric

Different entities can have the same attribute value

Page 7: Software Metrics

Many timesthe attribute of interest is not directly measurable .

An indirect measure involves a measure and a prediction formula

Page 8: Software Metrics

Example

density

mass volume

Page 9: Software Metrics

Software Measurement Theory

2 Kinds :

numerical relation system

empirical relation system

Page 10: Software Metrics

The empirical relation system

two parts:

A set of entities, E

A set of relationships, R

Page 11: Software Metrics

The numerical relation system

two parts:A set of entities, N

A set of relationships, P

EXP : Integers , Real

EXP : Less , Equal

Page 12: Software Metrics

MappingM, maps (E, R) to (N, P)

related in the empirical system

related in the numberical system

Page 13: Software Metrics

MappingM, maps (E, R) to (N, P)

related in the empirical system

related in the numberical system

x rel y if M(x) rel M(y)EXP :

Page 14: Software Metrics

EXP . Mapping

X height=< Y height and X weight =< Y weight

measure, BIG

Page 15: Software Metrics

MONOTONICITY

IF increase the value of attribute , the object Will not Reverse .

Page 16: Software Metrics

MONOTONICITY

IF increase the value of attribute , The object will not Reverse . Exp :

y = 5x - x 2X>0 And X<5

X>=5 And X<10

Increaes

DecreaseNot Monotonicity

y = X2

Monotonicity

Page 17: Software Metrics

MEASUREMENT SCALES

There are five different scale types :nominalordinal

intervalratio

absolute

Page 18: Software Metrics

NormalThis type basically assigns numbers or symbols without regard to any quantity

Page 19: Software Metrics

NormalThis type basically assigns numbers or symbols without regard to any quantity

EXP:

Page 20: Software Metrics

Ordinalthere is an implied ordering of the entities by the numbers assigned to the entity

Page 21: Software Metrics

Ordinalthere is an implied ordering of the entities by the numbers assigned to the entity

EXP:

Not Equal1

3 2

First – Second

Second - third

Page 22: Software Metrics

Intervalthe amount of the difference is constant

Page 23: Software Metrics

Intervalthe amount of the difference is constant

EXP: converting from a Celsius to a Fahrenheit

Formule : 9.5 x +32

Page 24: Software Metrics

Ratio

the amount of the difference is constant and Well Zero

Page 25: Software Metrics

absolute

The absolute is a counting scale measure

EXP:

Page 26: Software Metrics

Product Metrics

The most basic metric for size is the lines of code metric .

Product metrics are metrics that can be calculated from the document independent of how it was produced .

Page 27: Software Metrics

McCABE’S CYCLOMATIC NUMBER

introduced in 1976 .

Use the Gragh Theory : C = E – N + 2

C = Cyclomatic number .

N = number of Eodes .E = number of Edges .

Page 28: Software Metrics

McCABE’S CYCLOMATIC NUMBEREXP :

E = 11 N = 8 C = 11 – 8 + 2

C = 5

2 3 4 51

Page 29: Software Metrics

McCABE’S CYCLOMATIC NUMBER

Calculating the cyclomatic number from control flow graphs is time-consuming .

McCabe found a more directMethod of calculating his measure .

Page 30: Software Metrics

McCABE’S CYCLOMATIC NUMBER

IN source Code :

IF , For , While

Case or multiple Branch

1 decision

1 less decision

Restriction :

Page 31: Software Metrics

McCABE’S CYCLOMATIC NUMBER

Control flow graphs are required to have a distinct starting node and a distinct stopping node

C = D + 1D = Sum of Decisions

Formula :

Restriction … :

Page 32: Software Metrics

Example

E = 3D = 2

E = 2D = 1

E = 2D = 1

D = 4

Complexity C = 5

Page 33: Software Metrics

Threshold Value

If the Complexity is greater than 10, efforts should be made to reduce the value or to split the module

Page 34: Software Metrics

HALSTEAD’S SOFTWARE SCIENCE

He did his work in the late 1960s and 1970s.

He empirically looked for measures of intrinsic size

Page 35: Software Metrics

HALSTEAD’S SOFTWARE SCIENCE

variablesconstants

Operands

commasparenthesesarithmetic operatorsbrackets

Operator

Page 36: Software Metrics

Basic Measures—η1 and η2

η2 = Count of unique Operands Count of unique Operatorη1 =

η = η1 + η2 total count of unique tokensη =

Page 37: Software Metrics

Basic Measures—η1 and η2

Exp :z = 0;While x> 0 z = z + y ; x = x + 1;End –while ;Print(z) ;

Operator = ; > + - Print () While-endwhileOperand z x y 0 1

η1 =8 η2 = 5 η = 13

Page 38: Software Metrics

Length(N)

N2 = Count of OperandsCount of OperatorN1 =

N = N1 + N2

N = total count of tokens

Page 39: Software Metrics

LengthEXP :

z = 0;While x> 0 z = z + y ; x = x + 1;End –while ;Print(z) ;

Operators= 3; 5While 1> 1+ 1- 1Print 1() 1

OperandsZ 4X 3Y 20 21 1

N = N1 + N2 = 14+12 = 26

Page 40: Software Metrics

Estimate of the Length(est N)

est N = η1*log + η2*logη12 2

η2

Page 41: Software Metrics

Estimate of the Length(est N)

est N = η1*log + η2*log

Exp :η1=8 , η2=5

est N = 8*3 +5*2.32 = 35.6

η12 2

η2

Page 42: Software Metrics

Volume ( V )

V = N * Log 2(η1+ η2)

Volume = number of bits

Page 43: Software Metrics

Volume ( V )

V = N * Log 2(η1+ η2)

Volume = number of bits

Exp: N = 26 , η1=8 , η2=5

V = 26 * Log = 96.2213

Page 44: Software Metrics

Potential Volume, V*

V* = (2 + η2*)log2(2+ η2*)

Potential Volume = Min number of bits

η2* = The Minimal number of Operands

Page 45: Software Metrics

Implementation Level : L = V* / V

Other Parameter

Page 46: Software Metrics

Implementation Level : L = V* / V

Effort : E = V / L unit of Effors is emd

Other Parameter

Page 47: Software Metrics

Implementation Level : L = V* / V

Effort : E = V / L

Time: T = E / S

18 emd / sec

unit of Effors is emd

Other Parameter

Page 48: Software Metrics

HENRY–KAFURA INFORMATION FLOW

measure the intermodule complexity of source code .

In = into the moduleOut = out the module

i

i

Weight = weight the module

HK = Weight *(out * in )i i i i

i

Page 49: Software Metrics

HENRY–KAFURA INFORMATION FLOWExp : Weight = 1

HK = 1110