Software in Pictures 2008-03-12

Post on 26-Jun-2015

1.386 views 0 download

Tags:

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.

Transcript of Software in Pictures 2008-03-12

Software in pictures

Tudor Gîrbawww.tudorgirba.com

Software is complex.

The Standish Group, 2004

53% Challenged

18% Failed

29% Succeeded

How large is your project?

How large is your project?

1’000’000 lines of code

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

How large is your project?

1’000’000 lines of code

* 2 = 2’000’000 seconds

/ 3600 = 560 hours

/ 8 = 70 days

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

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

What are software metrics?

You cannot controlwhat you cannot measure.

Tom de Marco

Software metrics are measurements which

relate to software systems, processes or

related documents

Metrics compress the system into numbers.

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

McCabe, 1977

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

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Queries reduce the analysis space.

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

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

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

Software in pictures

Tudor Gîrbawww.tudorgirba.com

1946

1956

1956

1956

1956 2006

1956 2006

1956 2006

?1956 2006

Visualization compresses the system into pictures.

1854,London,choleraepidemic

1854,London,choleraepidemic

A picture is worth

a thousand words.

UML took it literally :)

We are

visualbeings.

How many groups do you see?

How many groups do you see?

How many groups do you see?

How many groups do you see?

Gestalt principles

proximity

enclosure connectivity

similarity

More Gestalt principles

closure continuity

We are

visualbeings.

A picture is worth

a thousand words.

UML took it literally :)

Example: what is ?

Polymetric views show up to 5 metrics.

Color metric

Width metric

Height metric

Position metrics

Lanza, 2003

System Complexity shows class hierarchies.

lines

attributes

methods

Lanza, Ducasse, 2003

Class Blueprint shows class internals.

Initialize Interface Internal Accessor Attribute

invocation and access direction

Lanza, Ducasse, 2005

Class Blueprint has a rich vocabulary.

Regular

Overriding

Extending

Abstract

Constant

Delegating

Setter

Getter

Method

invocations

lines

Attribute

internal access

externalaccess

Access

Invocation

Class Blueprint shows class internals.

Distribution Map shows properties over structure. Ducasse etal, 2006

31 parts, 394 elements and 9 properties

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

classes are buildings grouped in quarters of packages

Object Flow shows how objects move.Lienhard etal, 2007

objects flowing through other objects

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

forward engineering

actual development }

{

}

{

}

{

}

{}

{

}

{

}

{}

{

}

{

reve

rse

engin

eerin

g

reve

rse

engi

neer

ing

Spectographs show change activity.Wu etal, 2004

commit

time

Evolution Matrix shows changes in classes.

Idle class

Pulsar class

Supernova class

White dwarf class

Lanza, Ducasse, 2002

Evolution Matrix shows changes in classes

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

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

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 ...

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

Hierarchy Evolution reveals patterns.Girba etal, 2005

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

one package and its co-change relationships

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

}

{

}

{

}

{}

{

}

{

McCabe = 21

LOC =

753,0

00NOM = 102

Metrics Queries Visualizations ...

But, what actually happens

behind the scene?

1 node type1 edge type3 metrics

3 node types2 edge types3 metrics 8 properties

System Complexity

Class Blueprint

A small experiment

1, 13, 27, 4, 96

What were the numbers?

Easy!

What was the last advertisement you saw?

Not so easy!

Each visualization provides a language that needs to be learnt.

So, what does happen

behind the scene?

Principle: Minimize chart junk

Tufte, 1990

Excel default

Excel default

Excel default+6 actions

Distribution Map shows properties.Ducasse etal, 2006

Tufte, 1990

Principle: Maximize data ink

Tufte, 1990

InfoBug is cute and condensed.Chuah, Eick, 2006

So, what does happen

behind the scene?

Example 1: CVS shows activity.

Who did this?

Alphabetical order is no order.

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

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

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

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?

Clone Evolution shows how developers copy.Balint etal, 2006

Not every picture is worth a thousand words.

One more thing ...

Visualization is art, too.