33
Yann-Gaël Guéhéneuc This presentation has been given at OOPSLA, the 27 th of October 2004, in Vancouver, BC, Canada. Software Engineering Laboratory Department of Computing Science and Operations Research University of Montreal Département d’informatique École des Mines de Nantes © Yann-Gaël Guéhéneuc and Hervé Albin-Amiot Recovering Binary Class Relationships: Putting Icing on the UML Cake Hervé Albin-Amiot

OOPSLA04.ppt

Embed Size (px)

Citation preview

Page 1: OOPSLA04.ppt

Yann-Gaël Guéhéneuc

This presentation has been given at OOPSLA, the 27th of October 2004, in Vancouver, BC, Canada.

Software Engineering LaboratoryDepartment of Computing Science and Operations ResearchUniversity of Montreal

Département d’informatiqueÉcole des Mines de Nantes

© Yann-Gaël Guéhéneuc and Hervé Albin-Amiot

Recovering Binary Class Relationships:Putting Icing on the UML Cake

Hervé Albin-Amiot

Page 2: OOPSLA04.ppt

2/32

Statements

nMaintenance– 50% of the total cost of a program

n Program understanding– 50% of the maintainers’ time

n Any help in understanding a program would reduce its cost!

Page 3: OOPSLA04.ppt

3/32

Context

nOO maintenance– Source code

• Most accurate source of information

– Design models• Useful to understand source code

(architecture of a program)• Non-existent or obsolete

n Class diagrams help in understanding source code

Page 4: OOPSLA04.ppt

4/32

Approach

n Automated recovery of class diagrams from program source code– Extract relevant information– Operational semantics for relevant

constituents of class diagram– Consistent mapping

• Concepts in programming languages• Concepts in modeling languages

Page 5: OOPSLA04.ppt

5/32

Problem

n Use of our approach on Java and UML– UML class diagrams

• Only a notation! As emphasised during the panel on “Model Driven Architecture”

– Mapping• Semantic continuity for some concepts, such as

classes, fields, methods• Discontinuity for binary class relationships

Page 6: OOPSLA04.ppt

6/32

Is recovered as

Should be recovered as

Problem (cont’d)

Java

Page 7: OOPSLA04.ppt

6/32

Is recovered as

Should be recovered as

Problem (cont’d)

Java

Page 8: OOPSLA04.ppt

7/32

Proposal

n Study of the reverse-engineering of binary class relationships– “Consensual” definitions

• At design-level• At implementation-level

– Properties – Formalisations– Recovery algorithms

Page 9: OOPSLA04.ppt

8/32

Proposal (cont’d)

n Study of the reverse-engineering of binary class relationships– Mapping between programming and

modeling languages– Sound foundations

• Understanding• Round-tripping• Design patterns identification• … and much more!

Page 10: OOPSLA04.ppt

9/32

Overview

nMotivationsn Formalisationsn Recoveryn Validationsn Conclusion

Page 11: OOPSLA04.ppt

10/32

Definitions

n Up to now, no consensual definitionsn Study of more than 30 definitions

n “Consensual” definitionsLink Relationship

Origin Means Target Origin Name TargetInstance Direct Instance Entity Association EntityInstance Field Instance Class Aggregation EntityInstance Field +

Lifetime propertyInstance

Is d

escr

ibed

by

Class Composition Entity

“Entity” denotes either a class or an interface

Page 12: OOPSLA04.ppt

11/32

Definitions

n Association– At design-level

• Conceptual link between two classes• Multiple instances can be involved

– At implementation-level• Message sends between instances of two

classes, an origin and a target• Oriented, irreflexive, anti-symmetric at instance

and class level; asymmetric at instance level

Page 13: OOPSLA04.ppt

12/32

Definitions

n Aggregation– At design-level

• An aggregation relationship is an association between two classes: The whole and the part

– At implementation level• An aggregation relationship exists between

classes A and B when the definition of A, the whole, contains instances of B, its part

Page 14: OOPSLA04.ppt

13/32

Definitions

n Composition– At design-level

• Aggregation where parts are destroyed when their whole is destroyed

• Parts might be instantiated before the whole and exchanged

– At implementation level• Aggregation with constraint on the lifetimes and

on the ownership of the whole and of its part

Page 15: OOPSLA04.ppt

14/32

Properties

n Four minimal properties

– Exclusivity, an instance of B (b) is in relation with only one instance of A (a)

– Invocation site, for method invocations from a to b

– Lifetime, time of destruction of b wrt. a– Multiplicity, number of b’s for one a

Page 16: OOPSLA04.ppt

15/32

Properties

n Four minimal properties– Exclusivity, EX(A, B) ∈

– Invocation site, IS(A, B) ⊆ {field, parameter, local variable, …}

– Lifetime, LT(A, B) ∈ {+, −}

– Multiplicity, MU(A, B) ⊂ N ∪ {+∞}

Page 17: OOPSLA04.ppt

16/32

Formalisations

n Rewriting binary class relationships as conjunctions of their properties

n AssociationAS(A, B) =

(EX(A, B) ∈ B) ∧ (EX(B, A) ∈ B) ∧(IS(A, B) ⊆ {field…}) ∧ (IS(B, A) = ∅) ∧(LT(A, B) ∈ {+, −}) ∧ (LT(B, A) ∈ {+, −}) ∧(MU(A, B) = [0, +∞]) ∧ (MU(B, A) = [0, +∞])

Page 18: OOPSLA04.ppt

17/32

Formalisations

n AggregationAG(A, B) =

(EX(A, B) ∈ B) ∧(EX(B, A) ∈ B) ∧(IS(A, B) ⊆ {field, array field, collection field}) ∧(IS(B, A) = ∅) ∧(LT(A, B) ∈ {+, −}) ∧(LT(B, A) ∈ {+, −}) ∧(MU(A, B) = [0, +∞]) ∧(MU(B, A) = [1, +∞])

Page 19: OOPSLA04.ppt

18/32

Formalisations

n CompositionCO(A, B) =

(EX(A, B) = true) ∧(EX(B, A) = false) ∧(IS(A, B) ⊆ {field, array field, collection field}) ∧(IS(B, A) = ∅) ∧(LT(A, B) = +) ∧(LT(B, A) = −) ∧(MU(A, B) = [1, +∞]) ∧(MU(B, A) = [1, 1])

Page 20: OOPSLA04.ppt

19/32

Formalisations

n Emergent characteristics– Minimality of the set of properties

• See p. 307 of the proceedings

– Order among binary class relationships• Association• Aggregation• Composition

– Static and dynamic parts• IS(A, B), MU(A, B)• EX(A, B), LT(A, B)

Page 21: OOPSLA04.ppt

20/32

Overview

nMotivationsn Formalisationsn Recoveryn Validationsn Conclusion

Page 22: OOPSLA04.ppt

21/32

Recovery

n Binary class relationships – Not syntactical constructs in source code– Expressed with four minimal properties

n Recovery– Computation of the properties– Inference of existing relationships

Page 23: OOPSLA04.ppt

22/32

Recovery

n Algorithms– Static analyses

• IS(A, B), MU(A, B)

– Dynamic analyses• EX(A, B), LT(A, B)

Page 24: OOPSLA04.ppt

23/32

Recovery

n Algorithms– Order among the relationships– Association

• IS(A, B) with respect to other classes

– Aggregation• MU(A, B) with respect to associated classes

– Composition• EX(A, B)• LT(A, B)

with respect to aggregated classes

Page 25: OOPSLA04.ppt

24/32

Overview

nMotivationsn Formalisationsn Recoveryn Validationsn Conclusion

Page 26: OOPSLA04.ppt

25/32

Implementations

n Meta-model– PDL / PADL

n Static analyses– PatternsBox / Ptidej

n Dynamic analyses– Caffeine

Java

Model

Model + Associations, aggregations

Model + Associations, aggregations,

and composition

Caffeine

PatternsBox / Ptidej

Dedicated parser

PDL / PADL

PDL / PADL

PDL / PADL

Bytecodes

Page 27: OOPSLA04.ppt

26/32

Experimentations

n Case studies– Java AWT v1.2.2

• 367 classes

– JHotDraw v5.1• 171 classes

– JUnit v3.7• 45 classes

Page 28: OOPSLA04.ppt

27/32

Experimentations

n Association– 4,925 for 583 classes but required for aggregation

n Aggregation

n Composition– Precision and recall of 100% (JUnit only)

Frameworks Found Manual False HitsJava AWT 17 20 1JHotDraw 6 8 0JUnit 1 4 0Total 24 32 1

Recall: 0.75 Precision: 0.96

Page 29: OOPSLA04.ppt

28/32

Experimentations

n Emergent characteristics– Quantitative

• Possible metrics

– Qualitative• Assessment• Comparison

– Practicality

Page 30: OOPSLA04.ppt

29/32

Overview

nMotivationsn Formalisationsn Recoveryn Validationsn Conclusion

Page 31: OOPSLA04.ppt

30/32

Conclusion

n Any help in understanding a program would reduce its cost

n Automated recovery of class diagrams from program source code

nMapping for binary class relationships– “Consensual” definitions– Formalisations– Recovery algorithms

Page 32: OOPSLA04.ppt

31/32

Related work

n Civello at OOPSLA 1993

– Classification of binary class relationships– No operational semantics

n Henderson-Sellers and Barbier in L’Objet 1999

– Properties– Design-level

n Jackson and Waingold at ISCE 1999

– Operational semantics– Flavours of association, aggregation only

Page 33: OOPSLA04.ppt

32/32

Future work

n Detection of other UML constituents

n Static analyses vs. dynamic analyses

n Experimental validations– Maintainers– Class diagrams with/without binary

class relationships