Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

223
Pragmatic Design Quality Assessment Tudor Gîrba University of Bern, Switzerland Michele Lanza University of Lugano, Switzerland Radu Marinescu Politehnica University of Timisoara, Romania

description

This set of slides was used for the tutorial given by Tudor Girba, Michele Lanza and Radu Marinescu at International Conference on Software Engineering (ICSE) 2008.

Transcript of Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Page 2: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1946

Page 3: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951

Page 4: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951

Page 5: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951

Page 6: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951

Page 7: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951 2008

Page 8: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951 2008

Page 9: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1951 2008

Page 10: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

?1951 2008

Page 11: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is complex.

The Standish Group, 2004

53% Challenged

18% Failed

29% Succeeded

Page 12: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

Page 13: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

1’000’000 lines of code

Page 14: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

Page 15: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

Page 16: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

/ 8 = 70 days

Page 17: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

/ 8 = 70 days

/ 20 = 3 months

Page 18: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

But, code is for the computer.

Why would we ever read it?

Page 19: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

}

{

}

{

}

{

}

{

Page 20: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 21: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

What is the current state?

What should we do?

Where to start?

How to proceed?

Page 22: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

actual development

Page 23: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Reverse engineering is analyzing a subject system to:

identify components and their relationships, and

create more abstract representations.

Chikofky & Cross, 90

Page 24: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

}

{

}

{

}

{}

{

}

{

A large system contains lots of details.

Page 25: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

}

{

}

{

}

{}

{

}

{

A large system contains lots of details.

How to judge its quality?

Page 27: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1Software innumbers

2Software in

pictures

3Software in

time

4Software in

tools

Page 28: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1Software in numbers

Page 29: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

You cannot controlwhat you cannot measure.

Tom de Marco

Page 30: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metrics are functions that assign numbers to

products, processes and resources.

Page 31: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software metrics are measurements which

relate to software systems, processes or

related documents.

Page 32: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metrics compress system traits into numbers.

Page 33: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Let’s see some examples...

Page 34: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Examples of size metrics

NOM - number of methods

NOA - number of attributes

LOC - number of lines of code

NOS - number of statements

NOC - number of children

Lorenz, Kidd, 1994Chidamber, Kemerer, 1994

Page 35: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

McCabe, 1977

McCabe cyclomatic complexity (CYCLO) counts the number of independent paths through the code of a function.

interpretation can’t directly lead to improvement action

it reveals the minimum number of tests to write

Page 36: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Chidamber, Kemerer, 1994

Weighted Method Count (WMC) sums up the complexity of class’ methods (measured by the metric of your choice; usually CYCLO).

interpretation can’t directly lead to improvement action

it is configurable, thus adaptable to our precise needs

Page 37: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Chidamber, Kemerer, 1994

Depth of Inheritance Tree (DIT) is the (maximum) depth level of a class in a class hierarchy.

only the potential and not the real impact is quantified

inheritance is measured

Page 38: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Coupling between objects (CBO) shows the number of classes from which methods or attributes are used.

Chidamber, Kemerer, 1994

no differentiation of types and/or intensity of coupling

it takes into account real dependencies not just declared ones

Page 39: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Tight Class Cohesion (TCC) counts the relative number of method-pairs that access attributes of the class in common.

Bieman, Kang, 1995

TCC = 2 / 10 = 0.2

ratio values allow comparison between systems

interpretation can lead to improvement action

Page 40: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

...

Page 41: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

McCall, 1977

Page 42: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metrics Assess and Improve Quality!

Page 43: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metrics Assess and Improve Quality!

Really?

Page 44: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

McCall, 1977

Page 45: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

?Problem 1: metrics granularity

capture symptoms, not causes of problems

in isolation,they don’t lead to improvement solutions

Page 46: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

?Problem 2: implicit mapping

we don’t reason in terms of metrics, but in terms of design principles

Problem 1: metrics granularity

capture symptoms, not causes of problems

in isolation,they don’t lead to improvement solutions

Page 47: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

2 big obstacles in using metrics:

Thresholds make metrics hard to interpret

Granularity make metrics hard to use in isolation

Page 48: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Can metrics help me in what I really care for? :)

Page 49: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 50: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

Page 51: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

Page 52: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

How do I improve myself?

Page 53: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

How do I improve myself?

I want nothing to do with metrics!

Page 54: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How to get an initial understanding of a system?

Page 55: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metric ValueLOC 35175

NOM 3618

NOC 384

CYCLO 5579

NOP 19

CALLS 15128

FANOUT 8590

AHH 0.12

ANDC 0.31

Page 56: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metric ValueLOC 35175

NOM 3618

NOC 384

CYCLO 5579

NOP 19

CALLS 15128

FANOUT 8590

AHH 0.12

ANDC 0.31

Page 57: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Metric ValueLOC 35175

NOM 3618

NOC 384

CYCLO 5579

NOP 19

CALLS 15128

FANOUT 8590

AHH 0.12

ANDC 0.31And now what?

Page 58: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

We need means to compare.

Page 59: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

hierarchies?

coupling?

Page 60: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

Size Communication

Inheritance

Page 61: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

Size

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

Page 62: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

Communication

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

Page 63: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

Inheritance

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

Page 64: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

Page 65: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

...

HIGH

0.30

16

15

10

9

0.25

AVG

C++

4

5

0.20

LOW

Java

AVGLOW HIGH

0.24

10

13

7

0.20

10

0.16

7

4NOM/NOC

LOC/NOM

CYCLO/LOC

Page 66: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

close to high close to average close to low

Page 67: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

The Overview Pyramid provides a metrics overview. Lanza, Marinescu 2006

close to high close to average close to low

Page 68: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

How do I improve myself?

Page 69: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

How do I improve myself?

I want nothing to do with metrics!

Page 70: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How do I improve code?

Page 71: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Breaking design principles, rules and best practices

deteriorates the code;

it leads to design problems.

Quality is more than 0 bugs.

Page 72: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Imagine changing just a small design fragment

Page 73: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Imagine changing just a small design fragment

Page 74: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

and 33%of all classes would require changes

Imagine changing just a small design fragment

Page 75: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Design problems areexpensivefrequentunavoidable

Page 76: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Design problems areexpensivefrequentunavoidable

How to detect and eliminate them?

Page 77: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God Classes tend to centralize the intelligence of the system, to do everything and to use data from small data-classes.

Riel, 1996

Page 78: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God Classes tendto centralize the intelligence of the system,to do everything andto use data from small data-classes.

Page 79: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God Classescentralize the intelligence of the system,do everything anduse data from small data-classes.

Page 80: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God Classesare complex,are not cohesive,access external data.

Page 81: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God Classesare complex,are not cohesive,access external data.

Compose metrics into queries using

logical operato

rs

Page 82: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Detection Strategies are metric-based queries to detect design flaws.

METRIC 1 > Threshold 1

Rule 1

METRIC 2 < Threshold 2

Rule 2

AND Quality problem

Lanza, Marinescu 2006

Page 83: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

God

Class

Brain

Class

Feature

Envy

Data

Class

Brain

Method

Significant

Duplication

Intensive

Coupling

Extensive

Coupling

Shotgun

Surgery

Tradition

Breaker

Refused

Parent

Bequest

uses

has

is

has

has

has (partial)

is partially

has

is

is

has

Futile

Hierarchy

uses

has

has

is

has (subclass)

Classification

Disharmonies

Identity

Disharmonies

Collaboration

Disharmonies

Lanza, Marinescu 2006

Page 84: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A God Class centralizes too much intelligence in the system.

ATFD > FEW

Class uses directly more than a

few attributes of other classes

WMC ! VERY HIGH

Functional complexity of the

class is very high

TCC < ONE THIRD

Class cohesion is low

AND GodClass

Lanza, Marinescu 2006

Page 85: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

An Envious Method is more interested in data from a handful of classes.

ATFD > FEW

Method uses directly more than

a few attributes of other classes

LAA < ONE THIRD

Method uses far more attributes

of other classes than its own

FDP ! FEW

The used "foreign" attributes

belong to very few other classes

AND Feature Envy

Lanza, Marinescu 2006

Page 86: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Data Classes are dumb data holders.

WOC < ONE THIRD

Interface of class reveals data

rather than offering services

AND Data Class

Class reveals many attributes and is

not complex

Lanza, Marinescu 2006

Page 87: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Data Classes are dumb data holders.

AND

OR

Class reveals many

attributes and is not

complex

NOAP + NOAM > FEW

More than a few public

data

WMC < HIGH

Complexity of class is not

high

NOAP + NOAM > MANY

Class has many public

data

WMC < VERY HIGH

Complexity of class is not

very high

AND

Lanza, Marinescu 2006

Page 88: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 89: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

How do I understand code?

How do I improve code?

How do I improve myself?

Page 90: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How do I improve myself?

Page 91: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Follow a clear and repeatable process

Page 92: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Follow a clear and repeatable process

Page 93: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Follow a clear and repeatable process

Page 94: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Don’t reason about quality in terms of numbers!

Follow a clear and repeatable process

Page 96: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Can we understand the beauty of a paintingby measuring its frame or counting its colors?

Page 97: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1Software innumbers

2Software in

pictures

3Software in

time

4Software in

tools

Page 98: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

2Software in pictures

Page 99: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is beautiful

Page 100: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1854,London,choleraepidemic

Page 101: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1812, Napoleon’s Campaign in Russia

Page 102: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Numbers..

Page 103: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Numbers..

Page 104: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Numbers..

0.31ANDC

NOM

20.21 19

0.12

35175

NOP

NOC

418

0.15

8590

LOC

3618

9.42

5579

NOM

CALLS15128

384

FANOUT

9.72

0.56

AHH

CYCLO

Page 105: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Visualization compresses the system into pictures.

Page 106: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A picture is worth

a thousand words...

...depends on the picture

anonymous

Lanza

Page 107: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 108: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software visualiza

tion is more than UML

Page 109: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

We are

visualbeings ...

... and we’regood atspottingpatterns

Page 110: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How many groups do you see?

Page 111: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How many groups do you see?

Page 112: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How many groups do you see?

Page 113: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

How many groups do you see?

Page 114: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Gestalt principles

proximity

enclosure connectivity

similarity

Page 115: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

More Gestalt principles

closure continuity

Page 116: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

We do not see with our eyes, but with our brain.

Our brain works like a computer, with 3 types of memory

Iconic memory, the visual sensory register

Short-term memory, the working memory

Long-term memory

Sensation(Physical Process)

Perception(Cognitive Process)

Stimulus Sensory Organ Perceptual Organ

Brain

Iconic Memory - Short-term Memory - Long-term Memory

Page 117: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Iconicmemory

Short-termmemory

Page 118: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Iconicmemory

Short-termmemory

< 1 secondvery fastautomaticsubconscious

preattentive

Page 119: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Iconicmemory

Short-termmemory

< 1 secondvery fastautomaticsubconscious

preattentive

couple of seconds3-9 chunks

Page 120: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Categorizing Preattentive Attributes

Category Form Color Spatial Motion Motion

Attribute

Orientation Hue 2D position Flicker

Line length Intensity Direction

Line width

Size

Shape

Curvature

Added marks

Enclosure

Page 121: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Orientation Line Length Line Width Size

Shape Curvature Added Marks Enclosure

Page 122: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Line Length Line Width Size

Shape Curvature Added Marks Enclosure

Page 123: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Line Width Size

Shape Curvature Added Marks Enclosure

Page 124: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Size

Shape Curvature Added Marks Enclosure

Page 125: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Shape Curvature Added Marks Enclosure

Page 126: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Curvature Added Marks Enclosure

Page 127: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Added Marks Enclosure

Page 128: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Enclosure

Page 129: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Attributes of Form

Page 130: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Exemplifying Preattentive Processing

Page 131: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Exemplifying Preattentive Processing

8789364082376403128764532984732984732094873290845389274-0329874-32874-23198475098340983409832409832049823-0984903281453209481-0839393947896587436598

Page 132: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Exemplifying Preattentive Processing

8789364082376403128764532984732984732094873290845389274-0329874-32874-23198475098340983409832409832049823-0984903281453209481-0839393947896587436598

8789364082376403128764532984732984732094873290845389274-0329874-32874-23198475098340983409832409832049823-0984903281453209481-0839393947896587436598

Page 133: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

70%of all externalinputs comethrough the eyes

Page 134: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software visualization isthe use of the crafts of typography, graphic design, animation, and cinematography with modern human-computer interaction and computer graphics technology to facilitate both the human understanding and effective use of computer software.

Price, Becker, Small

Page 135: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Static Visualization

Page 136: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Dynamic Visualization

Page 137: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 138: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

no silver bullet

Page 139: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is complex

Page 140: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is complex

Page 141: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A picture is worth

a thousand words.

Page 142: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 143: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

UML took it literally

:)

Page 144: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Example: what is ?

Page 145: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 146: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 147: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 148: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 149: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 150: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Polymetric Views show up to 5 metrics.

Color metric

Width metric

Height metric

Position metrics

Lanza, 2003

Page 151: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A simple & powerful concept

LOC

NOS

lines

parameters

parameters

Page 152: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

System Complexity shows class hierarchies.

lines

attributes

methods

Lanza, Ducasse, 2003

Page 153: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Class Blueprint shows class internals.

Initialize Interface Internal Accessor Attribute

invocation and access direction

Lanza, Ducasse, 2005

Page 154: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Class Blueprint has a rich vocabulary.

Regular

Overriding

Extending

Abstract

Constant

Delegating

Setter

Getter

Method

invocations

lines

Attribute

internal access

externalaccess

Access

Invocation

Page 155: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Class Blueprint reveals patterns.

schizophrenic classtwin classes

Page 156: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Distribution Map shows properties over structure. Ducasse etal, 2006

31 parts, 394 elements and 9 properties

Page 157: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Softwarenaut explores the package structure.Lungu etal, 2006

Page 158: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Code City shows where your code lives.Wettel, Lanza, 2007

classes are buildings grouped in quarters of packages

Page 159: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 160: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 161: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 162: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 163: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 164: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 165: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 166: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Jmol - The Time Machine

Page 167: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is beautiful

Page 168: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1Software innumbers

2Software in

pictures

3Software in

time

4Software in

tools

Page 169: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

3Software in time

Page 170: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

actual development

Page 171: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

actual development

reve

rse

engi

neer

ing

Page 172: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

}

{

}

{

}

{}

{

}

{

A large system contains lots of details.

Page 173: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

}

{

}

{

}

{}

{

}

{

}

{

}

{

}

{}

{

}

{

}

{

}

{

}

{}

{

}

{

The history of a large system contains even more details.

}

{

}

{

}

{}

{

}

{

}

{

}

{

}

{}

{

}

{

Page 174: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Lehman etal, 2001

Most often time is put on the horizontaland a property on the vertical axis.

Page 175: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Spectographs show change activity.Wu etal, 2004

commit

time

Page 176: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Evolution Matrix shows changes in classes.

Idle class

Pulsar class

Supernova class

White dwarf class

Lanza, Ducasse, 2002

Page 177: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Evolution Matrix shows changes in classes.Lanza, Ducasse, 2002

Page 178: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

History can be measured.

Page 179: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

2 4 3 5 7

2 2 3 4 9

2 2 1 2 3

2 2 2 2 2

1 5 3 4 4

What changed? When did it change? ...

Page 180: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1 5 3 4 4

4 2 1 0+++ = 7=

LENOM(C) = ∑ |NOMi(C)-NOMi-1(C)| 2i-nEvolution ofNumber of Methods

LENOM(C)

Page 181: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1 5 3 4 4

LENOM(C) = ∑ |NOMi(C)-NOMi-1(C)| 2i-n

LENOM(C) 4 2-3 2 2-2 1 2-1 0 20+++ = 1.5=

EENOM(C) = ∑ |NOMi(C)-NOMi-1(C)| 22-i

Latest Evolution ofNumber of Methods

Earliest Evolution ofNumber of Methods

EENOM(C) 4 20 2 2-1 1 2-2 0 2-3+++ = 5.25=

Page 182: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

ENOM LENOM EENOM

7 3.5 3.25

7 5.75 1.37

3 1 2

0 0 0

7 1.25 5.25

2 4 3 5 7

2 2 3 4 9

2 2 1 2 3

2 2 2 2 2

1 5 3 4 4

Page 183: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

ENOM LENOM EENOM

7 3.5 3.25

7 5.75 1.37

3 1 2

0 0 0

7 1.25 5.25

balanced changer

late changer

dead stable

early changer

Page 184: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

ENOM LENOM EENOM

7 3.5 3.25

7 5.75 1.37

3 1 2

0 0 0

7 1.25 5.25

balanced changer

late changer

dead stable

early changer

History can be measured.

Page 185: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Evolution

Stability

Historical Max

Growth Trend

...

Number of Methods

Number of Lines of Code

Cyclomatic Complexity

Number of Modules

...

of

History can be measured in many ways.

Page 186: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

The recently changed parts are likely to change in the near future.

Common wisdom

Page 187: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

The recently changed parts are likely to change in the near future.

Common wisdom

Are they really?

Page 188: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

30% 90%

Page 189: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)
Page 190: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

Page 191: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past

Page 192: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past future

Page 193: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past future

Page 194: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past future

Page 195: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past future

YesterdayWeatherHit(present):

past:=histories.topLENOM(start, present) future:=histories.topEENOM(present, end)

past.intersectWith(future).notEmpty()

Page 196: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

present

past future

YesterdayWeatherHit(present):

past:=histories.topLENOM(start, present) future:=histories.topEENOM(present, end)

past.intersectWith(future).notEmpty()

prediction hit

Page 197: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Yesterday’s Weather shows the localization of changed in time. Girba etal, 2004

hit hit hit

YW = 3 / 8 = 37%

hit hit hit hit hit hit hit

YW = 7 / 8 = 87%

Page 198: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A God Class centralizes too much intelligence in the system.

ATFD > FEW

Class uses directly more than a

few attributes of other classes

WMC ! VERY HIGH

Functional complexity of the

class is very high

TCC < ONE THIRD

Class cohesion is low

AND GodClass

Lanza, Marinescu, 2006

Page 199: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

A God Class centralizes too much intelligence in the system.

ATFD > FEW

Class uses directly more than a

few attributes of other classes

WMC ! VERY HIGH

Functional complexity of the

class is very high

TCC < ONE THIRD

Class cohesion is low

AND GodClass

Lanza, Marinescu, 2006

But, what if it is

stable?

Page 200: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

History-based Detection Strategies take evolution into account. Ratiu etal, 2004

AND

isGodClass(last)

God Class

in the last version

Stability > 90%

Stable throughout

the history

Harmless God Class

Page 201: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

What happens with inheritance?

ver .1 ver. 2 ver. 3 ver. 4 ver. 5

A A A A A

B B B B BC C C

D D D E

A is persistent, B is stable, C was removed, E is newborn ...

Page 202: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Hierarchy Evolution encapsulates time.

A

B

D

C

E

age

changedmethods

changedlines

Removed

Removed

Girba etal, 2005

A is persistent, B is stable, C was removed, E is newborn ...

Page 203: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Hierarchy Evolution reveals patterns.Girba etal, 2005

Page 204: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Gall etal, 2003

Co-change analysis recovers hidden dependencies.Time is the lines.

Page 205: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Evolution Radar shows co-change relationships.D’Ambros, Lanza 2006

one package and its co-change relationships

Page 206: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Software is developed by people.

Page 207: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

CVS shows activity.

Page 208: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Who is responsible for this?

Page 209: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Who is responsible for this?

Page 210: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Alphabetical order is no order.

Page 211: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Ownership Map reveals development patterns.Girba etal, 2006

Page 212: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

JEdit

Page 213: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Ant

Page 214: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

(john 23.06.03) public boolean stillValid (ToDoItem I, Designer dsgr) {(bill 09.01.05) if (!isActive()) {(bill 09.01.05) return false(bill 09.01.05) }(steve 16.02.05) List offs = i.getOffenders();(john 23.06.03) Object dm = offs.firstElement();(steve 16.02.05) ListSet newOffs = computeOffenders(dm);(john 23.06.03) boolean res = offs.equals(newOffs);(john 23.06.03) return res;

(george 13.02.05) public boolean stillValid (ToDoItem I, Designer dsgr) {(bill 11.13.05) if (!isActive()) {(bill 11.13.05) return false(bill 11.13.05) }(steve 16.02.05) List offs = i.getOffenders();(george 13.02.05) Object dm = offs.firstElement();(steve 16.02.05) ListSet newOffs = computeOffenders(dm);(george 13.02.05) boolean res = offs.equals(newOffs);(george 13.02.05) return res;

Who copied from whom?

Page 215: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

(john 23.06.03) public boolean stillValid (ToDoItem I, Designer dsgr) {(bill 09.01.05) if (!isActive()) {(bill 09.01.05) return false(bill 09.01.05) }(steve 16.02.05) List offs = i.getOffenders();(john 23.06.03) Object dm = offs.firstElement();(steve 16.02.05) ListSet newOffs = computeOffenders(dm);(john 23.06.03) boolean res = offs.equals(newOffs);(john 23.06.03) return res;

(george 13.02.05) public boolean stillValid (ToDoItem I, Designer dsgr) {(bill 11.13.05) if (!isActive()) {(bill 11.13.05) return false(bill 11.13.05) }(steve 16.02.05) List offs = i.getOffenders();(george 13.02.05) Object dm = offs.firstElement();(steve 16.02.05) ListSet newOffs = computeOffenders(dm);(george 13.02.05) boolean res = offs.equals(newOffs);(george 13.02.05) return res;

What is useless?

Page 216: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

13.02.05 public boolean stillValid (ToDoItem I, Designer dsgr) {11.13.05 if (!isActive()) {11.13.05 return false11.13.05 }16.02.05 List offs = i.getOffenders();13.02.05 Object dm = offs.firstElement();16.02.05 ListSet newOffs = computeOffenders(dm);13.02.05 boolean res = offs.equals(newOffs);13.02.05 return res;

23.06.03 public boolean stillValid (ToDoItem I, Designer dsgr) {09.01.05 if (!isActive()) {09.01.05 return false09.01.05 }16.02.05 List offs = i.getOffenders();23.06.03 Object dm = offs.firstElement();16.02.05 ListSet newOffs = computeOffenders(dm);23.06.03 boolean res = offs.equals(newOffs);23.06.03 return res;

When did changes happen?

Page 217: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

Clone Evolution shows how developers copy.Balint etal, 2006

Page 218: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

reve

rse

engin

eerin

gforward engineering

}

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

actual development

reve

rse

engi

neer

ing

Page 219: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

1Software innumbers

2Software in

pictures

3Software in

time

4Software in

tools

Page 220: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

4Software in tools

Page 221: Pragmatic Design Quality Assessment - (Tutorial at ICSE 2008)

http://loose.upt.ro/incode

http://www.inf.unisi.ch/phd/wettel/codecity.html

http://moose.unibe.ch