More Related Content Similar to ASE06.ppt (20) More from Ptidej Team (20) ASE06.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
ASE 2006
September 18-22, 2006, Tokyo, Japan
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
Procedural thinking in OO programming
Lack of structure : no inheritance, no reuse, no
polymorphism
Long process-oriented methods with no
parameters and low cohesion
Excessive use of class and global variables for
processing
Moha © ASE 2006 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]
Metrics only : metrics cannot express important structural and semantic
properties
Lack of work on high-level DDs
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
Generation of
6
s1 Detection & Correction Algorithms
Step
Ste
ps
7
10
Method in 10 steps Application of
Detection & Correction Algorithms
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
Large controller class
Many fields and methods with a low cohesion
Dependent on the data stored in data classes
associated
Moha © ASE 2006 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
Generation of
6
s1 Detection & Correction Algorithms
Step
Ste
ps
7
10
Method in 10 steps
Application of
Detection & Correction Algorithms
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 Azureus GanttProject PMD QuickUML
113 KLOC 192 KLOC 22 KLOC 42 KLOC 9 KLOC Total
1230 classes 1449 classes 188 classes 423 classes 142 classes
Effectifs 91 143 19 15 3 271
70/91 82/143 10/19 3/15 1/3 166/271
Precisions
= 76.9% = 57.3% = 52.6% = 20% = 33.3% = 61.5%
Time 40.5s 2m 5.6s 31.6s 2.1s 3m 19.8s
Spaghetti Code
ArgoUML Azureus GanttProject PMD QuickUML Total
Effectifs 26 35 8 11 1 81
21/26 29/35 6/8 6/11 0/1 62/81
Precisions
= 80.7% = 82.8% = 75% = 54.5% = 0% = 76.6%
Time 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
13. Come see my poster !
Thursday, 21st
15:30 - 17:30
Room M3-M4
Moha © ASE 2006 Automatic Generation of Detection Algorithms for Design Defects 13