2. Context
n UML is a standard
– Used in industry
– Taught in universities
n UML is not a standard
– Imprecise
– Heavy
2/25
3. Problem
n But “lost” class diagrams
– Missing, out-of-date
n Maintenance > 50% of cost
– Program understanding > 50% of time
• Developers • Architecture
• Maintainers • Behaviour
• Design choices
3/25 • Implementation
4. Problem (cont’d)
n Lack of automated recovery tools
– Class diagrams
• Abstract
– Concentrate the essential qualities of anything more
extensive or of several things
(≠ Graphical representations of source code)
• Precise
– Extent to which a given measurement agrees with a
standard value
(Original and–or expected class diagrams)
4/25
6. Example
public class A { ... }
public class Example1 {
private A[] listOfAs = new A[10];
private int numberOfAs = 0;
public void addA(final A a) {
this.listOfAs[numberOfAs++] = a;
}
public A getA(final int index) {
return this.listOfAs[index];
}
public void removeA(final A a) {
// ...
}
public static void main(final String[] args) {
final Example1 example1 = new Example1();
example1.addA(new A());
5/25 // ...
}
}
7. Example
public class A { ... }
public class Example1 {
private A[] listOfAs = new A[10];
private int numberOfAs = 0;
public void addA(final A a) {
this.listOfAs[numberOfAs++] = a;
}
public A getA(final int index) {
return this.listOfAs[index];
}
public void removeA(final A a) {
// ...
}
public static void main(final String[] args) {
final Example1 example1 = new Example1();
example1.addA(new A());
5/25 // ...
}
}
9. Example (cont’d)
public class A { ... }
public class Example2 {
private List listOfAs = new ArrayList();
public void addA(final A a) {
this.listOfAs.add(a);
}
public A getA(final int index) {
return (A) this.listOfAs.remove(index);
}
public void removeA(final A a) {
this.listOfAs.remove(a);
}
public static void main(final String[] args) {
final Example2 example2 = new Example2();
example2.addA(new A());
// ...
6/25 }
}
10. Example (cont’d)
public class A { ... }
public class Example2 {
private List listOfAs = new ArrayList();
public void addA(final A a) {
this.listOfAs.add(a);
}
public A getA(final int index) {
return (A) this.listOfAs.remove(index);
}
public void removeA(final A a) {
this.listOfAs.remove(a);
}
public static void main(final String[] args) {
final Example2 example2 = new Example2();
example2.addA(new A());
// ...
6/25 }
}
14. Example (cont’d)
Precise Abstract
7/25 Association à Aggregation
15. Example (cont’d)
Precise Abstract
7/25 Association à Aggregation List is not important
16. Solution
n Systematic study of class diagram
constituents for their abstract and
precise recovery
– 34 constituents (UML meta-model)
– C++, Java, and Smalltalk
– Prototype tool
8/25
17. Related Work
n Numberof constituents of class
diagrams handled by tools
Recovered UML constituents in %
ArgoUML 7/34 21
Chava 7/34 21
Fujaba 7/34 21
IDEA 16/34 48
Rational Rose 8/34 24
Borland Together/J 8/34 24
Womble 9/34 28
9/25
18. Hypotheses
n Class-based programming languages
n Classdiagrams document design
during development and maintenance
n Context dependant definitions of the
constituents (⇒ incrementality)
10/25
19. Abstract, Precise
Systematic Study
n Classifier features
– Attribute üü
– Method üü
– Operations üû
• Abstract public methods
• Overloaded methods
• (Comments, documentation)
11/25
20. Abstract, Precise
Systematic Study
n Classifier relationships
– Binary association üü – N-ary association ûû
– Association end N/A – Aggregation üü
– Multiplicity üû – Composition üû
– Qualifier üû – Generalisation ûü
– Association class ûû – Dependency ûû
12/25
21. Abstract, Precise
Systematic Study
n Classifiers
– Class üü – Bound Element üü
– Nested class ûü – Metaclass üü
– Type üü – Powertype ûû
– Implementation class üü – Data Type üü
– Interface üü – Enumeration üü
– Parameterised class üü – Utility class üü
Relationships
Classifiers Attributes Operations M ethods to Other from Other
Classifiers
Class ü ü ü ü ü
Implementation Class ü û ü û û
Interface û ü û û ü
13/25 Type ü ü û ü ü
22. Abstract, Precise
Systematic Study
n Miscellaneous
– Stereotype üû – Link N/A
– Class pathname üü – Instance of üü
– Importing packages üü – Derived element
– Object N/A – List compartment N/A
– Composite object N/A – Name compartment N/A
14/25
23. Discussion
n Consensual definitions?
n Base of comparison?
15/25
24. Prototype Tool
n Ptidej
– Pattern Trace Identification, Detection, and
Enhancement in Java
• Also “breakfast” in French slang J
– Open framework for high-level program
analyses, visualisation, pattern detection
• More at www.ptidej.net
– Executable (.exe, .jar)
– Source code
16/25
25. Prototype Tool (cont’d)
n Ptidej
Abstract and
Precise Model
PADL
Meta-Model Transformations
based on the
Systematic Study
Model
Dedicated Parsers
C++
17/25 Java
26. Prototype Tool (cont’d)
n Ptidej
Recovered UML constituents in %
ArgoUML 7/34 21
Chava 7/34 21
Fujaba 7/34 21
IDEA 16/34 48
Ptidej 21/34 62
Rational Rose 8/34 24
Borland Together/J 8/34 24
Womble 9/34 28
18/25
27. Prototype Tool (cont’d)
n Ptidej
– Association, aggregation, and composition
binary class relationships
• Message sends
• Invocation sites
– Simple fields
– Arrays, collections
• Lifetime and exclusivity properties
19/25
29. Example revisited
public class A { ... }
public class Example1 {
private A[] listOfAs = new A[10];
private int numberOfAs = 0;
public void addA(final A a) {
this.listOfAs[numberOfAs++] = a;
}
public A getA(final int index) {
return this.listOfAs[index];
}
public void removeA(final A a) {
// ...
}
public static void main(final String[] args) {
final Example1 example1 = new Example1();
example1.addA(new A());
21/25 // ...
}
}
30. Example revisited
public class A { ... }
public class Example1 {
private A[] listOfAs = new A[10];
private int numberOfAs = 0;
public void addA(final A a) {
this.listOfAs[numberOfAs++] = a;
}
public A getA(final int index) {
return this.listOfAs[index];
}
public void removeA(final A a) {
// ...
}
public static void main(final String[] args) {
final Example1 example1 = new Example1();
example1.addA(new A());
21/25 // ...
}
}
31. Example revisited (cont’d)
public class A { ... }
public class Example2 {
private List listOfAs = new ArrayList();
public void addA(final A a) {
this.listOfAs.add(a);
}
public A getA(final int index) {
return (A) this.listOfAs.remove(index);
}
public void removeA(final A a) {
this.listOfAs.remove(a);
}
public static void main(final String[] args) {
final Example2 example2 = new Example2();
example2.addA(new A());
// ...
22/25 }
}
32. Example revisited (cont’d)
public class A { ... }
public class Example2 {
private List listOfAs = new ArrayList();
public void addA(final A a) {
this.listOfAs.add(a);
}
public A getA(final int index) {
return (A) this.listOfAs.remove(index);
}
public void removeA(final A a) {
this.listOfAs.remove(a);
}
public static void main(final String[] args) {
final Example2 example2 = new Example2();
example2.addA(new A());
// ...
22/25 }
}
36. Conclusion
n Exhaustive
and systematic study of
UML class diagram constituents
n Prototype tool implementing algorithms
for abstract and precise recovery
n Recovery of more constituents than any
other tools
24/25
37. Future Work
n UML v2.0
n Other programming languages
– Eiffel
n Other source of information
– Comments, names
– Documentation
n Other diagrams
– Sequence diagrams + Integration
n Base(s) of comparison
25/25