LECTURE 28: METRICS! CSE 442 Software Engineering Putting the E - - PowerPoint PPT Presentation

lecture 28 metrics
SMART_READER_LITE
LIVE PREVIEW

LECTURE 28: METRICS! CSE 442 Software Engineering Putting the E - - PowerPoint PPT Presentation

LECTURE 28: METRICS! CSE 442 Software Engineering Putting the E in SE Have mostly focused on creating software Putting the E in SE Have mostly focused on creating software Team Dynamics Putting the E in SE Have mostly focused on


slide-1
SLIDE 1

LECTURE 28: METRICS!

CSE 442 – Software Engineering

slide-2
SLIDE 2

¨ Have mostly focused on creating software

Putting the E in SE

slide-3
SLIDE 3

¨ Have mostly focused on creating software

¤ Team Dynamics

Putting the E in SE

slide-4
SLIDE 4

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management

Putting the E in SE

slide-5
SLIDE 5

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management ¤ Software Lifecycle

Putting the E in SE

slide-6
SLIDE 6

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management ¤ Software Lifecycle ¤ Requirements

Putting the E in SE

You want what?

slide-7
SLIDE 7

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management ¤ Software Lifecycle ¤ Requirements ¤ Design

Putting the E in SE

You want what?

slide-8
SLIDE 8

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management ¤ Software Lifecycle ¤ Requirements ¤ Design ¤ Testing

Putting the E in SE

slide-9
SLIDE 9

¨ Have mostly focused on creating software

¤ Team Dynamics ¤ Management ¤ Software Lifecycle ¤ Requirements ¤ Design ¤ Testing ¤ Implementation

Putting the E in SE

slide-10
SLIDE 10

¨ Demands attention to details, rules, precision…

Engineering Requirements

slide-11
SLIDE 11

¨ Demands attention to details, rules, precision…

… and numbers

Engineering Requirements

slide-12
SLIDE 12

¨ Demands attention to details, rules, precision…

… and numbers

¨ Results used to answer many types of questions:

¤ How much … ? ¤ How often … ? ¤ How many… ? ¤ Why?

Engineering Requirements

slide-13
SLIDE 13

¨ Provide data which drives process of engineering

¤ Allow us to make changes and evaluate results ¤ Apply scientific process to improve process & results

Metrics

slide-14
SLIDE 14

¨ Stop making all our decisions using intuition

Why We Use Metrics

slide-15
SLIDE 15

¨ Stop making all our decisions using intuition

to process relying on facts & evidence

Why We Use Metrics

slide-16
SLIDE 16

¨ Need solid basis by which number generated ¨ Number should accurately reflect reality

Numeric ≠ Useful

slide-17
SLIDE 17

Metric Problems

There are 3 kinds of lies:

  • 1. Lies
  • 2. Damned Lies
  • 3. Statistics
slide-18
SLIDE 18

¨ Misused metrics no better than random guess

¤ Much, much worse in most situations ¤ People’s faith & trust replaced by doubt

¨ Correlation is not causation – cannot forget this

Metric Problems

slide-19
SLIDE 19

¨ Fact: People with larger shoe sizes better spellers

Statistics Abuse

slide-20
SLIDE 20

¨ Fact: People with larger shoe sizes better spellers

Statistics Abuse

slide-21
SLIDE 21

¨ Fact: People with larger shoe sizes better spellers

Statistics Abuse

Adults good at spelling; Also wear grown-up shoes

slide-22
SLIDE 22

¨ Fact: People with larger shoe sizes better spellers

Statistics Abuse

Adults good at spelling; Also wear grown-up shoes Kids bad at spelling; Small feet use kids' sizes

slide-23
SLIDE 23

Why He Deserves a Raise

I wrote more code last year than any other employee

slide-24
SLIDE 24

And The Boss Replies…

slide-25
SLIDE 25

And The Boss Replies…

Measuring programming progress by lines of code is like measuring aircraft building progress by weight

slide-26
SLIDE 26

¨ Of these lines, which each equal to 1 LoC?

/* Some of these lines are really ugly */ int countMatches(E[] arr, E ignore) { int sum = (2 * 4) – (int)Math.sqrt(64); for (int i = 0; i < arr.length; i++) { E val = arr[i]; if (val.equals(ignore)) ; else { sum++; } } return sum; }

Lines Of Code

slide-27
SLIDE 27

What Are You Measuring?

slide-28
SLIDE 28

¨ Are you sure?

What Are You Measuring?

slide-29
SLIDE 29

¨ Cyclomatic complexity quick & easy to measure

¤ Equal to number of simple decisions + 1 ¤ || and && count also simple decisions

¨ Complexity is 4 for this example

¤ Written as V(G) = 4

¨ Provides deeper insight

¤ Counts different ways to screw up 2 1

Good Metric Example

3

slide-30
SLIDE 30

Good Metric Example

¨ Cyclomatic complexity quick & easy to measure

¤ Equal to number of simple decisions + 1 ¤ || and && count also simple decisions

¨ Complexity is 4 for this example

¤ Written as V(G) = 4

¨ Provides deeper insight

¤ Counts different ways to screw up 2 1 3

slide-31
SLIDE 31

Good Metric Example

¨ Cyclomatic complexity quick & easy to measure

¤ Equal to number of simple decisions + 1 ¤ || and && count also simple decisions

¨ Complexity is 4 for this example

¤ Written as V(G) = 4

¨ Provides deeper insight

¤ Counts different ways to screw up 2 1 3

slide-32
SLIDE 32

Good Metric Example

¨ Cyclomatic complexity quick & easy to measure

¤ Equal to number of simple decisions + 1 ¤ || and && count also simple decisions

¨ Complexity is 4 for this example

¤ Written as V(G) = 4

¨ Provides deeper insight

¤ Counts different ways to screw up 2 1 3

slide-33
SLIDE 33

What Makes it Good?

¨ Studies found V(G) correlated to error probability

¤ Opportunities for bugs much, much larger

¨ Inside complex methods find far more errors

V(G) # of Modules

20% of modules, but… 80% of bugs

slide-34
SLIDE 34

Is It Enough?

¨ Probability of bugs jumps once V(G) gets too large

¤ Often suggest rewrite methods w/ complexity > 7 ¤ V(G) > 9 demand rewrite or split into pieces

¨ Possible strategy: test complex methods only?

slide-35
SLIDE 35

Ego Check

¨ Who is the best programmer in the class?

slide-36
SLIDE 36

Ego Check

¨ Who is the best programmer in the class?

¤ How can you prove it?

slide-37
SLIDE 37

Real-World Questions

¨ Have 11 employees; but can only promote 3

slide-38
SLIDE 38

Real-World Questions

¨ Have 11 employees; but can only promote 3

¤ Whom do you promote?

slide-39
SLIDE 39

Real-World Questions

¨ Have 11 employees; but can only promote 3

¤ Whom do you promote? ¤ How will you explain your choice in court?

slide-40
SLIDE 40

Real-World Questions

¨ Changed the application lifecycle used

slide-41
SLIDE 41

Real-World Questions

¨ Changed the application lifecycle used

¤ 1st project sucked: client was an

slide-42
SLIDE 42

Real-World Questions

¨ Changed the application lifecycle used

¤ 1st project sucked: client was an ¤ How do you justify your decision to your boss?

slide-43
SLIDE 43

Singular of Data: Anecdote

¨ Single project cannot provide usable metrics

¤ Too many variables: must isolate cause-and-effect

¨ Results should converge given enough data

¤ If no convergence, results may be random ¤ May take time before convergence occurs

slide-44
SLIDE 44

Singular of Data: Anecdote

¨ Important to track metrics for large data set

¤ Many coders on single project ¤ Track group over long period of time

¨ Be careful evaluating metrics

¤ Limit evaluation to trends ¤ Smooth results by using moving averages

slide-45
SLIDE 45

Measurement Principles

¨ Define objectives first, collect data second

¤ Will always find patterns in data ¤ Simple coincidences should not be relied upon

slide-46
SLIDE 46

Measurement Principles

¨ Select metrics using theory valid for domain

¤ Analyze designs with design concepts not coding ¤ Verify positive results would be found

slide-47
SLIDE 47

Measurement Principles

¨ Tailor uses & analysis to answer your question

¤ If metric serves no purpose, do not collect that data ¤ Generate results you care about & not any others ¤ Check & double-check this does not bias results

slide-48
SLIDE 48

Once Analysis Is Complete

¨ Interpretation ¤ Look for insights about process ¤ Check how well/if metric represents the results ¤ Secondary effects of the process should be evaluated

¨ Answer the question: What do these results mean?

slide-49
SLIDE 49

Once Analysis Is Complete

¨ Interpretation ¤ Look for insights about process ¤ Check how well/if metric represents the results ¤ Secondary effects of the process should be evaluated

¨ Answer the question: What do these results mean?

slide-50
SLIDE 50

Most Important Step

¨ Feedback ¤ Recommend changes based upon the results ¤ Clarify confusing results by proposing additional experiments ¤ Verify work as good as possible and collect the big money

slide-51
SLIDE 51

Most Important Step

¨ Feedback ¤ Recommend changes based upon the results ¤ Clarify confusing results by proposing additional experiments ¤ Verify work as good as possible and collect the big money

slide-52
SLIDE 52

Most Important Step

¨ Feedback ¤ Recommend changes based upon the results ¤ Clarify confusing results by proposing additional experiments ¤ Verify work as good as possible and collect the big money

slide-53
SLIDE 53

How Much To Collect?

X

slide-54
SLIDE 54

Class-Oriented Metrics

¨ Size of each class ¨ Average method size ¨ Method complexity ¨ Weighted methods per class ¨ Average number of parameters per method

slide-55
SLIDE 55

Class-Oriented Metrics

¨ Number of subclasses ¨ Depth of the inheritance tree ¨ Number of overridden operations ¨ Number of added operations in subclass ¨ Specialization index