Page 1
Using Design Patterns and Constraints to Automate the Detection and Correction
of Inter-class Design Defects
Yann-Gaël Guéhéneuc ([email protected] )Hervé Albin-Amiot ([email protected] )
École des Mines de Nantes, France
Object TechnologyInternational Inc., Canada Soft-Maint S.A., France
Page 2
2/25
Design patterns
Constraints Inter-classdesign defects
The Ptidej tool To assess / to increase software flexibility and understandability
Page 3
3/25
Summary
n An overview of software qualityn A classification of design defectsnOn inter-class design defectsn Design pattern modelingn Design defects detectionn Design defects correctionn Case studiesn Conclusion and future work
Page 4
4/25
An overview of software quality
n Viewpoints– ISO/IEC 9126
• Functionality, reliability, usability, efficiency, maintainability, portability
– ISO/IEC 14598– Coupling, cohesion, method replacement…
nMaintenance = 75%n Design defects
Page 5
5/25
A classification of design defects
n Intra-class / Inter-class / Behavioral
Number: 39/61 (64%)Detection–correction: 25%
Number: 13/61 (21%)Detection–correction: 8%
Page 6
6/25
On inter-class design defects 1/2
n Design patterns– [Gamma et al. 1994]
• Quality architectural solutions• Language independent
– General Smalltalk- or C++-level
• Domain independent• Flexibility, understandability
– Other authors
Page 7
7/25
On inter-class design defects 2/2
nWanted software quality characteristics– Flexibility– Understandability
n Hypotheses– Groups of entities similar to a design
pattern = Inter-class design defects– Making these groups of entities closer to a
design pattern = Improving architectural quality (flexibility and understandability)
Page 8
8/25
Design pattern modeling 1/3
nMeta-model– Describe the entities and elements in
design pattern abstract models
n Abstract model– Describe a design pattern in term of roles
n Concrete model– Link an abstract model to real code
Page 9
9/25
Meta-model 2/3BasicA Example:
Page 10
10/25
Informal descriptions from [Gamma et al.]
Instance of class PDelegation
Instance of class PInterface
Instance of class PClass
Instance of class PAssoc
name() Instance of class PMethod
Instance of class Pattern
Pattern, PInterface, PClass, PAssoc, PDelegation, and PMethod are classes defined in our meta-model
Translates into
Composite 3/3BasicA Example:
Page 11
11/25
Design pattern detection 1/4
n Design pattern abstract model– Detection rules, i.e., constraints
• Roles as variables• Relationships as constraints among variables
n CSP– Source code for domain– Abstract model for variables, constraints
Page 12
12/25
Source code 1 Source code nComposite pattern abstract model
BasicA Example: Composite 2/4
Composite pattern concrete model 1 Composite pattern concrete model n
CSP CSP
Distorted concrete models
Page 13
13/25
Design pattern detection 3/4
n Distorted concrete models– The design pattern– Not quite
• Some constraints are not verified
n Back to our hypotheses– Groups of entities similar to a design
pattern
Page 14
14/25
Design pattern detection 4/4
n Explanation-based Constraint Programming [Jussien]– Set of constraints justifying an action
performed by the PaLM solver• Value removal• Contradiction
– Strong interactivity with the user through dynamic removal / addition of constraints
Page 15
15/25
n The Ptidej tool– Hypotheses– Design pattern abstract models– Design pattern concrete models– Inter-class design defects
• Detection• Correction
Inter-class design defects 1/5
Page 16
16/25
Ptidej 2/5BasicA Example:
Page 17
17/25
Ptidej 3/5BasicA Example:
Page 18
18/25
Ptidej 4/5BasicA Example:
Page 19
19/25
Ptidej 5/5BasicA Example:
Page 20
20/25
Case studies 1/4
n Several applications being reviewed– Small test-cases– HotJava v3.0 (~90 classes)– JEdit v3.1 (~250 classes)– JHotDraw v5.1 (~155 classes)– JUnit v3.2 (~90 classes)
Page 21
21/25
Case studies 2/4
Page 22
22/25
Case studies 3/4
Page 23
23/25
Case studies 4/4
Page 24
24/25
Conclusion and future work
n Design patterns + Constraints +Inter-class design defects
– To assess / to increase software flexibility and understandability
n Semantics, scalability, software quality characteristics, automation, interaction, weights, noise, hybrid
Page 25
25/25
Questions?
Comments?
Thank you for your attention
Yann-Gaël Guéhéneuc ([email protected] )Hervé Albin-Amiot ([email protected] )
Object Technology International Inc.
Soft-Maint S.A.
École des Mines de Nantes