Software Measurement Theory Measurement part 2 1 Measurement

  • Slides: 21
Download presentation
Software Measurement Theory Measurement - part 2 1

Software Measurement Theory Measurement - part 2 1

Measurement Theory u circa 1900 - applied to physics u 1940’s - applied to

Measurement Theory u circa 1900 - applied to physics u 1940’s - applied to psychology, sociology u 1990’s - applied to software measurement Measurement - part 2 2

Representational TOM u empirical relation system – (C, R) u numerical relation system –

Representational TOM u empirical relation system – (C, R) u numerical relation system – (N, P) u. M maps (C, R) to (N, P) u representation condition – x<y => M(x)<M(y) Measurement - part 2 3

Empirical u. A set of entities, E u A set of relationships, R –

Empirical u. A set of entities, E u A set of relationships, R – often “less than” or “less than or equal” – note that not everything has to be related Measurement - part 2 4

Numerical u A set of entities – also called the “answer set” – usually

Numerical u A set of entities – also called the “answer set” – usually numbers - natural numbers, integers or reals u. A set of relations – usually already exists – often “less than” or “less than or equal” Measurement - part 2 5

The Mapping u The representation condition – M(x) rel M(y) if x rel y

The Mapping u The representation condition – M(x) rel M(y) if x rel y – x rel y iff M(x) rel M(y) u Both have been used by classical measurement theory authors u I prefer the first definition Measurement - part 2 6

“BIG” example u We want to measure people as BIG – i. e. height

“BIG” example u We want to measure people as BIG – i. e. height and weight u Empirically, if two people are the same height, the heavier is bigger – if two people are the same weight, the taller is bigger u Answer set is real or tuple? Measurement - part 2 7

Classic Example u Mc. Cabe’s Cyclomatic Number u Empirical - Control Flow Graph u

Classic Example u Mc. Cabe’s Cyclomatic Number u Empirical - Control Flow Graph u Numerical (Answer Set) - integers u mapping - E-N+2 Measurement - part 2 8

Empirical u How can we rank Mc. Cabe’s? u What is the relationship? u

Empirical u How can we rank Mc. Cabe’s? u What is the relationship? u What is a partial order? Measurement - part 2 9

Creating a New Theory Why should a theory devised for physical phenomenon be useful

Creating a New Theory Why should a theory devised for physical phenomenon be useful for software - an artificial phenomenon? Measurement - part 2 10

Empirical Relations u One cludge that appears very often in the computer science literature

Empirical Relations u 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 u The truth is that we do not have centuries of consensus on the empirical relationships Measurement - part 2 11

Artificial u Software has been described as an artificial science because we control the

Artificial u Software has been described as an artificial science because we control the objects. In fact, the objects are artifacts - made by humans u However, if there are constraints on these artifacts, it is usually in the operations that can change the artifacts Measurement - part 2 12

Transformations u Consider the transformations that you can do to a syntactically correct program

Transformations u 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 Measurement - part 2 13

MOM u Model - Order - Mapping u the model is the abstraction u

MOM u Model - Order - Mapping u the model is the abstraction u the order is an ordering on the abstraction – can be partial, can be constructive u the mapping is from the model to the answer set – must preserve the order (I. e. rep condition) Measurement - part 2 14

MOM Measurement - part 2 15

MOM Measurement - part 2 15

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 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; Measurement - part 2 16

Triangle CFG 1, 2, 3 a 3 b 4 a 4 b 5 a

Triangle CFG 1, 2, 3 a 3 b 4 a 4 b 5 a 5 b 6 a 6 b 7 Measurement - part 2 17

Formal Spec u CFG is described by set of nodes {1, 3 b, 4

Formal Spec u CFG is described by set of nodes {1, 3 b, 4 a, 4 b, 5 a, 5 b, 6 a, 6 b, 7} and set of arcs {(1, 3 b), (1, 4 a), (3 b, 4 a), (4 a, 4 b), (4 a, 5 a), (4 b, 5 a), (5 a, 5 b), (5 a, 6 a), (5 b, 6 a), (6 a, 6 b), (6 a, 7), (6 b, 7) Measurement - part 2 18

Partial Order u Originally, for all cfg x, y, x <=y if and only

Partial Order u Originally, for all cfg x, y, x <=y if and only if all nodes and edges in x are also in y. u 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 u Constructive definition - x <= y if there is a set of transforms (additive) such that the transforms are applied to x produce y Measurement - part 2 19

Representation Condition u Can prove that for all cfg’s x and y, if x<=y

Representation Condition u Can prove that for all cfg’s x and y, if x<=y then m(x) <= m(y) u Note that this is not the iff rep condition. Since the partial orders on the abstractions are partial, if can only be one way Measurement - part 2 20

Proof of monotonicity u Can show that no additive transform can decrease the cfg

Proof of monotonicity u Can show that no additive transform can decrease the cfg or the value of the mapping u 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 Measurement - part 2 21