111
Software in pictures Tudor Gîrba www.tudorgirba.com

Software in Pictures 2008-03-12

Embed Size (px)

DESCRIPTION

Understanding software systems is hampered by their sheer size and complexity. Software visualization encodes the data found in these systems into pictures and enables the human eye to interpret it. In this lecture we present the concepts of software visualization and we show several examples of how visualizations can help in understanding software systems.

Citation preview

Page 1: Software in Pictures 2008-03-12

Software in pictures

Tudor Gîrbawww.tudorgirba.com

Page 2: Software in Pictures 2008-03-12

Software is complex.

The Standish Group, 2004

53% Challenged

18% Failed

29% Succeeded

Page 3: Software in Pictures 2008-03-12

How large is your project?

Page 4: Software in Pictures 2008-03-12

How large is your project?

1’000’000 lines of code

Page 5: Software in Pictures 2008-03-12

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

Page 6: Software in Pictures 2008-03-12

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

Page 7: Software in Pictures 2008-03-12

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

/ 8 = 70 days

Page 8: Software in Pictures 2008-03-12

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 9: Software in Pictures 2008-03-12

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

Page 10: Software in Pictures 2008-03-12

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

Page 11: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 12: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 13: Software in Pictures 2008-03-12

What are software metrics?

Page 14: Software in Pictures 2008-03-12

You cannot controlwhat you cannot measure.

Tom de Marco

Page 15: Software in Pictures 2008-03-12

Software metrics are measurements which

relate to software systems, processes or

related documents

Page 16: Software in Pictures 2008-03-12

Metrics compress the system into numbers.

Page 17: Software in Pictures 2008-03-12

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

Lorentz, Kidd, 1994Chidamber, 1994

Page 18: Software in Pictures 2008-03-12

McCabe, 1977

McCabe cyclomatic complexity counts the number of possible paths through the code of a function.

Page 19: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 20: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 21: Software in Pictures 2008-03-12

Queries reduce the analysis space.

Page 22: Software in Pictures 2008-03-12

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 23: Software in Pictures 2008-03-12

Example: 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 24: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 25: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 26: Software in Pictures 2008-03-12

Software in pictures

Tudor Gîrbawww.tudorgirba.com

Page 27: Software in Pictures 2008-03-12

1946

Page 28: Software in Pictures 2008-03-12

1956

Page 29: Software in Pictures 2008-03-12

1956

Page 30: Software in Pictures 2008-03-12

1956

Page 31: Software in Pictures 2008-03-12

1956 2006

Page 32: Software in Pictures 2008-03-12

1956 2006

Page 33: Software in Pictures 2008-03-12

1956 2006

Page 34: Software in Pictures 2008-03-12

?1956 2006

Page 35: Software in Pictures 2008-03-12

Visualization compresses the system into pictures.

Page 36: Software in Pictures 2008-03-12

1854,London,choleraepidemic

Page 37: Software in Pictures 2008-03-12

1854,London,choleraepidemic

Page 38: Software in Pictures 2008-03-12

A picture is worth

a thousand words.

Page 39: Software in Pictures 2008-03-12
Page 40: Software in Pictures 2008-03-12

UML took it literally :)

Page 41: Software in Pictures 2008-03-12

We are

visualbeings.

Page 42: Software in Pictures 2008-03-12

How many groups do you see?

Page 43: Software in Pictures 2008-03-12

How many groups do you see?

Page 44: Software in Pictures 2008-03-12

How many groups do you see?

Page 45: Software in Pictures 2008-03-12

How many groups do you see?

Page 46: Software in Pictures 2008-03-12

Gestalt principles

proximity

enclosure connectivity

similarity

Page 47: Software in Pictures 2008-03-12

More Gestalt principles

closure continuity

Page 48: Software in Pictures 2008-03-12

We are

visualbeings.

Page 49: Software in Pictures 2008-03-12

A picture is worth

a thousand words.

Page 50: Software in Pictures 2008-03-12
Page 51: Software in Pictures 2008-03-12

UML took it literally :)

Page 52: Software in Pictures 2008-03-12

Example: what is ?

Page 53: Software in Pictures 2008-03-12
Page 54: Software in Pictures 2008-03-12
Page 55: Software in Pictures 2008-03-12
Page 56: Software in Pictures 2008-03-12
Page 57: Software in Pictures 2008-03-12
Page 58: Software in Pictures 2008-03-12

Polymetric views show up to 5 metrics.

Color metric

Width metric

Height metric

Position metrics

Lanza, 2003

Page 59: Software in Pictures 2008-03-12

System Complexity shows class hierarchies.

lines

attributes

methods

Lanza, Ducasse, 2003

Page 60: Software in Pictures 2008-03-12

Class Blueprint shows class internals.

Initialize Interface Internal Accessor Attribute

invocation and access direction

Lanza, Ducasse, 2005

Page 61: Software in Pictures 2008-03-12

Class Blueprint has a rich vocabulary.

Regular

Overriding

Extending

Abstract

Constant

Delegating

Setter

Getter

Method

invocations

lines

Attribute

internal access

externalaccess

Access

Invocation

Page 62: Software in Pictures 2008-03-12

Class Blueprint shows class internals.

Page 63: Software in Pictures 2008-03-12

Distribution Map shows properties over structure. Ducasse etal, 2006

31 parts, 394 elements and 9 properties

Page 64: Software in Pictures 2008-03-12

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

classes are buildings grouped in quarters of packages

Page 65: Software in Pictures 2008-03-12

Object Flow shows how objects move.Lienhard etal, 2007

objects flowing through other objects

Page 66: Software in Pictures 2008-03-12

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

Page 67: Software in Pictures 2008-03-12

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

reve

rse

engi

neer

ing

Page 68: Software in Pictures 2008-03-12

Spectographs show change activity.Wu etal, 2004

commit

time

Page 69: Software in Pictures 2008-03-12

Evolution Matrix shows changes in classes.

Idle class

Pulsar class

Supernova class

White dwarf class

Lanza, Ducasse, 2002

Page 70: Software in Pictures 2008-03-12

Evolution Matrix shows changes in classes

Page 71: Software in Pictures 2008-03-12

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

Page 72: Software in Pictures 2008-03-12

History contains too much data.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Page 73: Software in Pictures 2008-03-12

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 74: Software in Pictures 2008-03-12

Hierarchy Evolution encapsulates time.

A

B

D

C

E

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

age

changedmethods

changedlines

Removed

Removed

Girba etal, 2005

Page 75: Software in Pictures 2008-03-12

Hierarchy Evolution reveals patterns.Girba etal, 2005

Page 76: Software in Pictures 2008-03-12

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

one package and its co-change relationships

Page 77: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 78: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 80: Software in Pictures 2008-03-12

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Page 81: Software in Pictures 2008-03-12

But, what actually happens

behind the scene?

Page 82: Software in Pictures 2008-03-12

1 node type1 edge type3 metrics

3 node types2 edge types3 metrics 8 properties

System Complexity

Class Blueprint

Page 83: Software in Pictures 2008-03-12

A small experiment

Page 84: Software in Pictures 2008-03-12

1, 13, 27, 4, 96

Page 85: Software in Pictures 2008-03-12

What were the numbers?

Page 86: Software in Pictures 2008-03-12

Easy!

Page 87: Software in Pictures 2008-03-12

What was the last advertisement you saw?

Page 88: Software in Pictures 2008-03-12

Not so easy!

Page 89: Software in Pictures 2008-03-12

Each visualization provides a language that needs to be learnt.

Page 90: Software in Pictures 2008-03-12

So, what does happen

behind the scene?

Page 91: Software in Pictures 2008-03-12

Principle: Minimize chart junk

Tufte, 1990

Page 92: Software in Pictures 2008-03-12

Excel default

Page 93: Software in Pictures 2008-03-12

Excel default

Excel default+6 actions

Page 94: Software in Pictures 2008-03-12

Distribution Map shows properties.Ducasse etal, 2006

Page 95: Software in Pictures 2008-03-12

Tufte, 1990

Principle: Maximize data ink

Tufte, 1990

Page 96: Software in Pictures 2008-03-12

InfoBug is cute and condensed.Chuah, Eick, 2006

Page 97: Software in Pictures 2008-03-12

So, what does happen

behind the scene?

Page 98: Software in Pictures 2008-03-12

Example 1: CVS shows activity.

Page 99: Software in Pictures 2008-03-12

Who did this?

Page 100: Software in Pictures 2008-03-12

Alphabetical order is no order.

Page 101: Software in Pictures 2008-03-12

Ownership Map orders histories to reveal patterns. Girba etal, 2006

Page 102: Software in Pictures 2008-03-12

(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;

Example 2: Who copied from whom?

Page 103: Software in Pictures 2008-03-12

(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 104: Software in Pictures 2008-03-12

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 105: Software in Pictures 2008-03-12

Clone Evolution shows how developers copy.Balint etal, 2006

Page 106: Software in Pictures 2008-03-12

Not every picture is worth a thousand words.

Page 107: Software in Pictures 2008-03-12

One more thing ...

Page 108: Software in Pictures 2008-03-12

Visualization is art, too.

Page 109: Software in Pictures 2008-03-12
Page 110: Software in Pictures 2008-03-12