Weitere ähnliche Inhalte Ähnlich wie Cascon06 tooldemo.ppt (20) Mehr von Ptidej Team (20) Kürzlich hochgeladen (20) Cascon06 tooldemo.ppt1. Automatic Generation of
Detection Algorithms for Design Defects
Naouel Moha, Yann-Gaël Guéhéneuc, Pierre Leduc
Ptidej team, GEODES, University of Montreal, Canada
LIFL, INRIA project Jacquard, University of Lille, France
CASCON 2006
October 17-20, 2006, Toronto, Canada
2. Context
Design Patterns are “good” solutions to recurring design problems
Design Defects (DDs)
are “bad” solutions to recurring problems
2 categories:
High-level (global) problems: antipatterns [BRO 98]
Low-level (local) problems: code smells [FOW 99]
Why it is important to detect DDs ?
DDs lessen the quality of OO architectures and impede their
evolution and their maintenance
Maintenance is expensive because of DDs [PER 92] : adding,
debugging, and evolving of features are difficult
A good software architecture without DDs: easier to understand,
change, and thus maintain
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
2
3. Context
2 examples of high-level DDs
Blob
Large controller class
Many fields and methods with a low cohesion*
Dependent on the data stored in associated
data classes
*How closely the methods are related to the instance variables
in the class. Measure: LCOM (Lack of Cohesion Metric)
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
3
4. Context
2 examples of high-level DDs
Spaghetti Code
Lack of structure : no inheritance, no reuse, no
polymorphism
Long process-oriented methods with no
parameters and low cohesion
Moha © ASE 2006
Procedural thinking in OO programming
Excessive use of class and global variables for
processing
Automatic Generation of Detection Algorithms for Design Defects
4
5. Problem Description
What are the problems ?
Textual descriptions of DDs [Brown 98] [Fowler 99]
Lack of precision and misinterpretations
Difficult to build detection algorithms from textual descriptions
Lack of precise specifications and tools: metrics only
[Marinescu 04]
[Tools: SmallLint, PMD]
Lack of work on high-level DDs
Metrics only : metrics cannot express important structural and semantic
properties
Focus only on low-level DDs (code smells)
Semi-manual detection [Marinescu 04] [Munro 05]
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
5
6. Solution
How to address these problems ?
We propose a language and a framework
to specify precisely high-level DDs in order
to ease and automate their detection
We define a systematic method, called DECOR, to specify high-level DDs
significantly and to generate detection and correction algorithms
from the specifications of DDs
Method in 10 steps
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
6
7. Our Approach
We define a systematic method, called DECOR, to specify high-level DDs
significantly and to generate detection and correction algorithms
from the specifications of DDs
Illustration with the Blob
Blob
Many fields and methods with a low cohesion
Moha © ASE 2006
Large controller class
Dependent on the data stored in data classes
associated
Automatic Generation of Detection Algorithms for Design Defects
7
8. Specification of Design Defects
Rule Cards
More structured description
RULE_CARD : Blob {
RULE : Blob {ASSOC: associated FROM: MainClass ONE TO: DataClass MANY } ;
RULE : MainClass {UNION LargeClassLowCohesion ControllerClass } ;
RULE : LargeClassLowCohesion {UNION LargeClass LowCohesion } ;
RULE : LargeClass { (METRIC: NMD + NAD, VERY_HIGH) } ;
RULE : LowCohesion { (METRIC: LCOM5, VERY_HIGH) } ;
RULE : ControllerClass {UNION (SEMANTIC: METHODNAME, {Process, Main, Ctrl})
(SEMANTIC: CLASSNAME, {Process, Main, Ctrl)};
RULE : DataClass { (STRUCT: METHOD, Accessor) } ;
} ;
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
8
9. Generation of Detection Algorithms
SAD Framework (Software Architectural Defects)
A meta-model to instantiate rule cards of DDs
A parser to analyse and reify rule cards
A repository of metrics
Services to analyse structural relationships
Services to perform semantic and structural analyses
Concrete Generation
1. Parse the rule card
2. Build a model representing this rule card
3. Visit the model of the rule card
4. Generate the detection algorithm
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
9
10. Our Approach
We define a systematic method, called DECOR, to specify high-level DDs
significantly and to generate detection and correction algorithms
from the specifications of DDs
Method in 10 steps
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
10
11. Preliminary Results
We specify and detect DDs in several open-source programs
Blob
ArgoUML
Precisions
Time
GanttProject
PMD
QuickUML
113 KLOC
1230 classes
Effectifs
Azureus
192 KLOC
1449 classes
22 KLOC
188 classes
42 KLOC
423 classes
9 KLOC
142 classes
Total
91
143
19
15
3
271
70/91
= 76.9%
82/143
= 57.3%
10/19
= 52.6%
3/15
= 20%
1/3
= 33.3%
166/271
= 61.5%
40.5s
2m
5.6s
31.6s
2.1s
3m 19.8s
Spaghetti Code
ArgoUML
Effectifs
Precisions
Time
Azureus
GanttProject
PMD
QuickUML
Total
26
35
8
11
1
81
21/26
= 80.7%
29/35
= 82.8%
6/8
= 75%
6/11
= 54.5%
0/1
= 0%
62/81
= 76.6%
39s
1m55s
5.4s
31s
1.9s
3m12s
Results are encouraging !
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
11
12. Conclusion
Contributions
Meta-model enriched with semantic and structural
properties
Rule-based Language & Framework
Method DECOR in 10 steps
Our approach
A systematic method based on a meta-model and a rule-based
language to generate automatically detection and correction
algos of high-level DDs
Future Work
Correction of DDs
More defects and case studies including commercial programs
Use of a dictionnary such as WordNet for semantics
Moha © ASE 2006
Automatic Generation of Detection Algorithms for Design Defects
12