measurement - part 2 1 software measurement measurement theory

21
Measurement - part 2 1 Software Measurement Measurement Theory

Upload: blake-lawrence

Post on 18-Jan-2016

249 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 1

Software Measurement

Measurement Theory

Page 2: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 2

Measurement Theory

circa 1900 - applied to physics 1940’s - applied to psychology, sociology 1990’s - applied to software measurement

Page 3: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 3

Representational TOM

empirical relation system– (C,R)

numerical relation system– (N,P)

M maps (C,R) to (N,P) representation condition

– x<y => M(x)<M(y)

Page 4: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 4

Empirical

A set of entities, E A set of relationships, R

– often “less than” or “less than or equal”– note that not everything has to be related

Page 5: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 5

Numerical

A set of entities– also called the “answer set”– usually numbers - natural numbers, integers or

reals A set of relations

– usually already exists– often “less than” or “less than or equal”

Page 6: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 6

The Mapping

The representation condition– M(x) rel M(y) if x rel y– x rel y iff M(x) rel M(y)

Both have been used by classical measurement theory authors

I prefer the first definition

Page 7: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 7

“BIG” example

We want to measure people as BIG– i.e. height and weight

Empirically, if two people are the same height, the heavier is bigger– if two people are the same weight, the taller is

bigger Answer set is real or tuple?

Page 8: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 8

Classic Example

McCabe’s Cyclomatic Number Empirical - Control Flow Graph Numerical (Answer Set) - integers mapping - E-N+2

Page 9: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 9

Empirical

How can we rank McCabe’s?

What is the relationship?

What is a partial order?

Page 10: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 10

Creating a New Theory

Why should a theory devised for physical phenomenon be useful for

software - an artificial phenomenon?

Page 11: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 11

Empirical Relations

One cludge that appears very often in the computer science literature is to define the empirical relation as that which makes the representation condition hold for the measure

The truth is that we do not have centuries of consensus on the empirical relationships

Page 12: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 12

Artificial

Software has been described as an artificial science because we control the objects. In fact, the objects are artifacts - made by humans

However, if there are constraints on these artifacts, it is usually in the operations that can change the artifacts

Page 13: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 13

Transformations

Consider the transformations that you can do to a syntactically correct program that maintains the correctness:– add a statement– add a condition– remove a statement

Page 14: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 14

MOM

Model - Order - Mapping the model is the abstraction the order is an ordering on the abstraction

– can be partial, can be constructive the mapping is from the model to the

answer set– must preserve the order (I.e. rep condition)

Page 15: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 15

MOM

Page 16: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 16

Triangle Problem

cin>>a>>b>>c;type=“scalene”;if (a==b||b==c||a==c) type=“isosceles”;if (a==b&&b==c) type=“equilateral”;if (a>=b+c||b>=a+c||c>=a+b) type=“not a triangle”;if (a<=0||b<=0||c<=0) type=“bad inputs”;cout<<type;

Page 17: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 17

Triangle CFG1,2,3a

3b

4a

4b

5a

5b6a

6b7

Page 18: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 18

Formal Spec

CFG is described by set of nodes {1,3b,4a,4b,5a,5b,6a,6b,7} and set of arcs {(1,3b),(1,4a),(3b,4a),(4a,4b),(4a,5a), (4b,5a), (5a,5b),(5a,6a),(5b,6a),(6a,6b), (6a,7),(6b,7)

Page 19: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 19

Partial Order

Originally, for all cfg x,y, x <=y if and only if all nodes and edges in x are also in y.

Thus adding an edge to x made a new cfg y such that x <= y but y may not be a cfg for a valid program

Constructive definition - x <= y if there is a set of transforms (additive) such that the transforms are applied to x produce y

Page 20: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 20

Representation Condition

Can prove that for all cfg’s x and y, if x<=y then m(x) <= m(y)

Note that this is not the iff rep condition. Since the partial orders on the abstractions are partial, if can only be one way

Page 21: Measurement - part 2 1 Software Measurement Measurement Theory

Measurement - part 2 21

Proof of monotonicity

Can show that no additive transform can decrease the cfg or the value of the mapping

Can show that additive transforms of adding if-then, if-then-else, while will always result in an increase of 1 in the value of the mapping