85
The anatomy of analysis tools Tudor Gîrba www.tudorgirba.com

The Anatomy of Analysis Tools (EVO 2008)

Embed Size (px)

DESCRIPTION

I used this set of slides for a lecture I gave at the University of Berne.

Citation preview

Page 1: The Anatomy of Analysis Tools (EVO 2008)

The anatomy of analysis tools

Tudor Gîrbawww.tudorgirba.com

Page 2: The Anatomy of Analysis Tools (EVO 2008)

Lanza, Ducasse 2003

Page 3: The Anatomy of Analysis Tools (EVO 2008)

Lanza, Ducasse 2003

How is it implemented?

Page 4: The Anatomy of Analysis Tools (EVO 2008)

But, why should you care?

Page 5: The Anatomy of Analysis Tools (EVO 2008)

When we understand our anatomy

we understand better the healing process

Page 6: The Anatomy of Analysis Tools (EVO 2008)

Terminology

Page 7: The Anatomy of Analysis Tools (EVO 2008)

what is a model?

Page 8: The Anatomy of Analysis Tools (EVO 2008)

model

model

framework

theoretical account

poser

simulation

exampleexemplar

good example

role model

fashion model

manakin

manikin

mannequin

mannikin

modelingmodelling

form

kind

sort

variety

NOUNS

framework, model, theoretical account

a simplified description of a complex entity or process

"the computer program was based on a model of the circulatory and respiratory systems"

Page 9: The Anatomy of Analysis Tools (EVO 2008)

a model is a simplification of the subject,

and its purpose is to answer some particular

questions aimed towards the subject.

Bezivin, Gerbe 2001

Page 10: The Anatomy of Analysis Tools (EVO 2008)

what does meta mean?

Page 11: The Anatomy of Analysis Tools (EVO 2008)

μετά = beyond

Page 12: The Anatomy of Analysis Tools (EVO 2008)

Aristotle384 BC - 322 BC

Page 13: The Anatomy of Analysis Tools (EVO 2008)

what is a meta-model?

Page 14: The Anatomy of Analysis Tools (EVO 2008)

a meta-model isa model that makes statements aboutwhat can be expressed in valid models.

Seidewitz 2003

Page 15: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

Page 16: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

representedBy

Page 17: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

representedBy

instanceOf

Page 18: The Anatomy of Analysis Tools (EVO 2008)

database

subject

schema

representedBy

instanceOf

Page 19: The Anatomy of Analysis Tools (EVO 2008)

object

subject

class

representedBy

instanceOf

Page 20: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

representedBy

instanceOf

Page 21: The Anatomy of Analysis Tools (EVO 2008)

TerminologyAnalysis and meta-models

Page 22: The Anatomy of Analysis Tools (EVO 2008)

What is an analysis?

Page 23: The Anatomy of Analysis Tools (EVO 2008)

TCC = ?

Page 24: The Anatomy of Analysis Tools (EVO 2008)

Bieman, Kang, 1995

TCC = 2 / 10 = 0.2

TCC =method pairs accessing common attributes

total number of pairs

Page 25: The Anatomy of Analysis Tools (EVO 2008)

What is an analysis?

Page 26: The Anatomy of Analysis Tools (EVO 2008)

Oxford Dictionary

analysis |əˈnaləsis|noun (pl. -ses |-ˌsēz|)

Detailed examination of the elements or structure of something, typically as a basis for discussion or interpretation.

The process of separating something into its constituent elements. Often contrasted with synthesis.

Page 27: The Anatomy of Analysis Tools (EVO 2008)

Oxford Dictionary

synthesis |ˈsinθəsis|noun ( pl. -ses |-ˌsēz|)

Combination or composition. Often contrasted with analysis.

Page 28: The Anatomy of Analysis Tools (EVO 2008)

Data InformationAnalysis

Page 29: The Anatomy of Analysis Tools (EVO 2008)

TCC = ?

Page 30: The Anatomy of Analysis Tools (EVO 2008)

tightClassCohesion (classSource) count = 0 methodCount = methodBodies(classSource) attributes = attributes(classSource) methodsToAttributes = new Dictionary for (methodBody in methodBodies(classSource)) accessedAttributes = new Set for (statement in methodBody) accessedAttributes.add(attributesIn(statement)) end methodsToAttributes.put(methodBody, accessedAttributes) end for (methodToAttributes in methodsToAttributes) for (attribute in methodToAttributes.value) for (methodToAttributes2 in methodsToAttributes) if (methodToAttributes.value.contains(attribute) & methodToAttributes ~= methodToAttributes2) count++ end end end end return count / methodCount * (methodCount - 1) / 2 end

Page 31: The Anatomy of Analysis Tools (EVO 2008)

tightClassCohesion (classSource) count = 0 methodCount = methodBodies(classSource) attributes = attributes(classSource) methodsToAttributes = new Dictionary for (methodBody in methodBodies(classSource)) accessedAttributes = new Set for (statement in methodBody) accessedAttributes.add(attributesIn(statement)) end methodsToAttributes.put(methodBody, accessedAttributes) end for (methodToAttributes in methodsToAttributes) for (attribute in methodToAttributes.value) for (methodToAttributes2 in methodsToAttributes) if (methodToAttributes.value.contains(attribute) & methodToAttributes ~= methodToAttributes2) count++ end end end end return count / methodCount * (methodCount - 1) / 2 end

Page 32: The Anatomy of Analysis Tools (EVO 2008)

Class::tightClassCohesion () count = 0 methodCount = this.methods.size() for (attribute in this.attributes) temp = attribute.accessingMethods() count = count + temp * (temp - 1) / 2 end return count / methodCount * (methodCount - 1) / 2end

Page 33: The Anatomy of Analysis Tools (EVO 2008)

Class

Method

Attribute

*

belongsTo

*

belongsTo

Class::tightClassCohesion () count = 0 methodCount = this.methods.size() for (attribute in this.attributes) temp = attribute.accessingMethods() count = count + temp * (temp - 1) / 2 end return count / methodCount * (methodCount - 1) / 2end

Page 34: The Anatomy of Analysis Tools (EVO 2008)

Class

Method

Attribute

*

belongsTo

*

belongsTo

Class::tightClassCohesion () count = 0 methodCount = this.methods.size() for (attribute in this.attributes) temp = attribute.accessingMethods() count = count + temp * (temp - 1) / 2 end return count / methodCount * (methodCount - 1) / 2end

?

Page 35: The Anatomy of Analysis Tools (EVO 2008)

A good meta-model enables easy navigation

Class

Method

Attribute

Access

Inheritance

Package

Namespace

*

belongsTo

*

belongsTo

belongsTopackagedIn

superclass

subclass

* *

InvocationinvokedBy

candidate

*

accessedIn

*

accesses

*

*

*

*

Page 36: The Anatomy of Analysis Tools (EVO 2008)

A meta-model offers

a language

Page 37: The Anatomy of Analysis Tools (EVO 2008)

A common meta-model offers

a common language

Page 38: The Anatomy of Analysis Tools (EVO 2008)

(FAMIX.Class (id: 100) (name 'Server') (container (ref: 82)) (isAbstract false) (isInterface false) (package (ref: 624)) (stub false) (NOM 9) (WLOC 124)) (FAMIX.Method (id: 101) (name 'accept') (signature 'accept(Visitor v)') (parentClass (ref: 100)) (accessControl 'public') (hasClassScope false) (stub false) (LOC 7) (CYCLO 3))

Page 39: The Anatomy of Analysis Tools (EVO 2008)

(FAMIX.Class (id: 100) (name 'Server') (container (ref: 82)) (isAbstract false) (isInterface false) (package (ref: 624)) (stub false) (NOM 9) (WLOC 124)) (FAMIX.Method (id: 101) (name 'accept') (signature 'accept(Visitor v)') (parentClass (ref: 100)) (accessControl 'public') (hasClassScope false) (stub false) (LOC 7) (CYCLO 3))

Tools that implement a common

meta-model can exchange models

Page 40: The Anatomy of Analysis Tools (EVO 2008)
Page 41: The Anatomy of Analysis Tools (EVO 2008)
Page 42: The Anatomy of Analysis Tools (EVO 2008)

Analyses specified on a meta-model can

be applied on any complying model

Page 43: The Anatomy of Analysis Tools (EVO 2008)

ClassMethod

Inheritance

Attribute

Page 44: The Anatomy of Analysis Tools (EVO 2008)

File

ClassMethod

Inheritance

Attribute

Page 45: The Anatomy of Analysis Tools (EVO 2008)

Symbol

File

ClassMethod

Inheritance

Attribute

Page 46: The Anatomy of Analysis Tools (EVO 2008)

Author

Symbol

File

ClassMethod

Inheritance

Attribute

Page 47: The Anatomy of Analysis Tools (EVO 2008)

Author

Symbol

File

ClassMethod

Duplication

Inheritance

Attribute

Page 48: The Anatomy of Analysis Tools (EVO 2008)

Author

ClassHistory

Symbol

File

ClassVersion

ClassMethod

Duplication

Inheritance

Attribute

Page 49: The Anatomy of Analysis Tools (EVO 2008)

Author

ClassHistory

Trace Symbol

FileEvent

ClassVersion

ClassMethod

Duplication

Inheritance

Attribute

Page 50: The Anatomy of Analysis Tools (EVO 2008)

Author

ClassHistory

Trace Symbol

FileEvent

ClassVersion

ClassMethod

Duplication

Inheritance

. . .

Attribute

Page 51: The Anatomy of Analysis Tools (EVO 2008)

A good meta-model makes things explicit

Page 52: The Anatomy of Analysis Tools (EVO 2008)

TerminologyAnalysis and meta-modelsAnalysis tools

Page 53: The Anatomy of Analysis Tools (EVO 2008)

Model repository described by a meta-model

Analysis Analysis Analysis

Fact extractorFact extractor

Page 54: The Anatomy of Analysis Tools (EVO 2008)

Repository Fame MondrianUIFAMIX EyeSee

Page 55: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

Smalltalk

FAMIX EyeSee

Page 56: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

SmalltalkJava

C++

iPlasma

FAMIX EyeSee

Page 57: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

SmalltalkJava

C++

iPlasma

FAMIX EyeSee

Page 58: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

SmalltalkJava

C++

iPlasma

FAMIX

HapaxDynaMooseChronia SmallDude

EyeSee

CodeCityYellowSubmarine

Page 59: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

SmalltalkJava

C++

iPlasma

FAMIX

HapaxDynaMooseChronia SmallDude

EyeSee

CVS

CodeCity

MSE SourceJ-Wiretap

YellowSubmarine

SVN

Page 60: The Anatomy of Analysis Tools (EVO 2008)

MSE

Repository Fame MondrianUI

SmalltalkJava

C++

iPlasma

FAMIX

HapaxDynaMooseChronia SmallDude

EyeSee

CVS

CodeCity

MSE SourceJ-Wiretap

YellowSubmarine

SVN

Softwarenaut BugsLife Clustering Metanool ...

Page 61: The Anatomy of Analysis Tools (EVO 2008)

TerminologyAnalysis and meta-modelsAnalysis toolsAnalysis as transformation

Page 62: The Anatomy of Analysis Tools (EVO 2008)

Data InformationAnalysis

Page 63: The Anatomy of Analysis Tools (EVO 2008)

Meta-model TechniqueGlue

Analysis

Page 64: The Anatomy of Analysis Tools (EVO 2008)

Meyer etal 2006

e.g., Mondrian

Page 65: The Anatomy of Analysis Tools (EVO 2008)

Mondrian is about

visualization

Page 66: The Anatomy of Analysis Tools (EVO 2008)
Page 67: The Anatomy of Analysis Tools (EVO 2008)
Page 68: The Anatomy of Analysis Tools (EVO 2008)

Composition with Red, Yellow and Blue Piet Mondrian (1921)

Page 69: The Anatomy of Analysis Tools (EVO 2008)

The simplest script is an empty view

view := ViewRenderer new.

view open.

Page 70: The Anatomy of Analysis Tools (EVO 2008)

view = nodes, edges, layout

view := ViewRenderer new.

view nodes: classes.

view edges: classes

from: [:each | each superclass]

to: [:each | each].

view treeLayout.

view open.

Page 71: The Anatomy of Analysis Tools (EVO 2008)

Shapes are responsible for drawing

view := ViewRenderer new.

view newShape rectangle;

height: [:each | each numberOfMethods];

withBorder.

view nodes: classes.

view edges: classes

from: [:each | each superclass]

to: [:each | each].

view treeLayout.

view open.

Page 72: The Anatomy of Analysis Tools (EVO 2008)

Blocks can be replaced by symbols

view := ViewRenderer new.

view newShape rectangle;

height: #numberOfMethods;

withBorder.

view nodes: classes.

view edgesFrom: #superclass.

view treeLayout.

view open.

Page 73: The Anatomy of Analysis Tools (EVO 2008)

Nesting is done through blocks

view := ViewRenderer new.

view newShape rectangle; withBorder.

view nodes: classes forEach: [:each |

view nodes: each methods.

view gridLayout

].

view edgesFrom: #superclass.

view treeLayout.

view open.

Page 74: The Anatomy of Analysis Tools (EVO 2008)

Mondrian is about

visualization

Page 75: The Anatomy of Analysis Tools (EVO 2008)

Mondrian is about

interactive visualization

Page 76: The Anatomy of Analysis Tools (EVO 2008)

Interaction is scriptable, too

view := ViewRenderer new.

view2 := ViewRenderer new.

view interaction onSelect: [:each | each viewOn: view2].

view interaction

popupView: [:each :aView | each viewOn: aView].

...

view open.

view2 open.

Page 77: The Anatomy of Analysis Tools (EVO 2008)

How is it implemented?

Page 78: The Anatomy of Analysis Tools (EVO 2008)

view newShap

e rectangle;

height:

#numberOfMe

thods;

width:

#numberOfAtt

ributes;

linearF

illColor: #n

umberOfLines

OfCode

within: c

lasses;

withBor

der.

view nodes:

classes.

view edgesFr

om: #supercl

ass.

view treeLay

out.

Page 79: The Anatomy of Analysis Tools (EVO 2008)

TerminologyAnalysis and meta-modelsAnalysis toolsAnalysis as transformationIssues

Page 80: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model What to model?

Page 81: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

another model

another meta-model

Page 82: The Anatomy of Analysis Tools (EVO 2008)

model

subject

meta-model

What gets extracted?

Page 83: The Anatomy of Analysis Tools (EVO 2008)

Is the technique suitable for your task?

Page 84: The Anatomy of Analysis Tools (EVO 2008)

The meta-model dictates the problem decomposition