FehmiFehmiFehmiFehmi JaafarJaafarJaafarJaafar, Yann, Yann, Yann, Yann----GaëlGaëlGaëlGaël GuéhéneucGuéhéneucGuéhéneucGuéhéneuc,,,, aaaannnndddd SSSSyyyyllllvvvviiiieeee HHHHaaaammmmeeeellll
DIRO, Université de Montréal, QC, Canada
1
1.1.1.1. IntroductionIntroductionIntroductionIntroduction
2.2.2.2. RelatedRelatedRelatedRelated WorkWorkWorkWork
3.3.3.3. ProblemProblemProblemProblem StatementStatementStatementStatement
4.4.4.4. EmpiricalEmpiricalEmpiricalEmpirical StudyStudyStudyStudy
5.5.5.5. ResearchResearchResearchResearch QuestionQuestionQuestionQuestion5.5.5.5. ResearchResearchResearchResearch QuestionQuestionQuestionQuestion
6.6.6.6. ResultsResultsResultsResults
7.7.7.7. OngoingOngoingOngoingOngoing WorkWorkWorkWork
8.8.8.8. ConclusionConclusionConclusionConclusion
2
Anti-patterns are motifs that are commonly used by developers but
they are ineffective and counterproductive in program development
and–or maintenance.
Opposite to anti-patterns, design patterns are “good” solutions to
recurring design problems, conceived to increase reuse, code quality,
code readability and, above all, maintainability and resilience tocode readability and, above all, maintainability and resilience to
changes.
These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies.
3
VokacVokacVokacVokac[1][1][1][1] analyzed the corrective maintenance of a large commercial
program, compared the defect rates of classes participating in design
motifs against those that did not.
Observer and Singleton motifs are correlated with larger classes
Classes playing roles in Factory Method were more compact, less
coupled, and less defect prone than others classes.
No clear tendency exists for Template Method.
PietrzakPietrzakPietrzakPietrzak andandandand WalterWalterWalterWalter[2][2][2][2] defined and analyzed the different relationshipsPietrzakPietrzakPietrzakPietrzak andandandand WalterWalterWalterWalter defined and analyzed the different relationships
that exist among smells.
These relationships presented dependencies between smells and
could be exploited to improve the detection tools of anti-patterns.
4
[1] M. Vokac, “Defect frequency and design patterns: An empirical study
of industrial code,” IEEE Trans. Softw. Eng., vol. 30, December 2004.
[2] B. Pietrzak and B. Walter, “Leveraging code smell detection with inter-
smell relations,” Extreme Programming and Agile Processes in Software
Engineering, pp. 75–84, 2006.
Most previous work agree that anti-patterns make the maintenance of
systems more difficult and that design patterns can serve as guide in
program exploration and, thus, ease maintenance.
However, there are no investigation in the literature about the static
relationships among anti-patterns and design patterns.
Better understand systems by giving knowledge about theBetter understand systems by giving knowledge about the
dependencies between what is “good” and what is “bad” in system.
Explain the co-existence of such motifs
5
org.apache.xerces.validators.common.XMLValidator.java
r315086 | twl | 1999-11-08 20:10:52 -0500 (Mon, 08 Nov 1999)r315086 | twl | 1999-11-08 20:10:52 -0500 (Mon, 08 Nov 1999)
Initial revision
org.apache.xerces.validators.dtd.DTDImporter.java
r315397 | jeffreyr | 2000-04-04 15:38:39 -0400 (Tue, 04 Apr
2000)
Factoring Validators code by Glenn Marcy
6
We use the Defect DEtection for CORrection Approach (DECOR [3])
to specify and detect anti-patterns.
We use the Design Motif Identification Multilayered Approach
(DeMIMA [4]) to detect design patterns and static relationships
7
[4] Naouel Moha, Y.-G. Guéhéneuc, L. Duchien, and A.-F. Le Meur,
“DECOR: A method for the specification and detection of code and
design smells,” Transactions on Software Engineering (TSE), vol. 36, no.
1, 2010.
Y.-G. Guéhéneuc and G. Antoniol, “DeMIMA: A multilayered framework
for design pattern identification,” Transactions on Software Engineering
(TSE), vol. 34, no. 5, pp. 667–684, 2008.
SystemSystemSystemSystem AntiAntiAntiAnti----patternpatternpatternpattern Design patternDesign patternDesign patternDesign pattern StaticStaticStaticStatic
relationshiprelationshiprelationshiprelationship
ArgoUML ComplexClass Command Use
JFreeChart LongMethod Composite Association
XercesJ LongParameterList Decorator Agregation
MessageChains FactoryMethod CompositionMessageChains FactoryMethod Composition
RefusedParentBequest Prototype
SpaghettiCode Observer
SpeculativeGenerality
SwissArmyKnife
8
Are there static relationships between antiAre there static relationships between antiAre there static relationships between antiAre there static relationships between anti----
patternspatternspatternspatterns andandandand designdesigndesigndesign patterns?patterns?patterns?patterns?
We assume that a design pattern P has a static relationships with the
anti-pattern A if at least one class belonging to P has a use, association,
aggregation, or composition relationship with one class belonging to A.
9
10
11
12
Different anti-patterns can have different proportions of static
relationships with design patterns.
The design pattern that often has the most relationships with anti
patterns is the Command design pattern.
For example, we noted that 50% of static relationships among
SpeculativeGenerality and design patterns in ArgoUML, are with the
Command motifs.
In XercesJ, we observe that 41% of relationships among
ClassDataShouldBePrivate was with the Command design pattern.
13
SpaghettiCodes have no static relationships (use, association,
aggregation, and composition) with design patterns.
SpaghettiCode are revealed by classes with no structure, declaring long
methods with no parameters, and using global variables for processing.
14
A SpaghettiCode does not take the advantage of object-orientation
mechanisms: polymorphism and inheritance.
SpaghettiCodes are difficult to reuse and to maintain.
The evolution of relationships among motifs.
15
Prevent the co-exsitence of anti-patterns and design patterns.
Studying the effect of the anti-patterns dependencies on change-proneness.
The relation between classes having static dependencies with anti-patterns
and fault-proneness.
The relation between classes co-changed with anti-patterns and fault-
proneness.
We provide empirical evidence of the relationships between anti-patterns
and design patterns.
Some anti-patterns are significantly more likely to have relationships with
design patterns than other.
We provide a basis for future research to understand the causes and the
eventual consequences of these relationships.
16
eventual consequences of these relationships.

Ppap13a.ppt

  • 1.
    FehmiFehmiFehmiFehmi JaafarJaafarJaafarJaafar, Yann,Yann, Yann, Yann----GaëlGaëlGaëlGaël GuéhéneucGuéhéneucGuéhéneucGuéhéneuc,,,, aaaannnndddd SSSSyyyyllllvvvviiiieeee HHHHaaaammmmeeeellll DIRO, Université de Montréal, QC, Canada 1
  • 2.
    1.1.1.1. IntroductionIntroductionIntroductionIntroduction 2.2.2.2. RelatedRelatedRelatedRelatedWorkWorkWorkWork 3.3.3.3. ProblemProblemProblemProblem StatementStatementStatementStatement 4.4.4.4. EmpiricalEmpiricalEmpiricalEmpirical StudyStudyStudyStudy 5.5.5.5. ResearchResearchResearchResearch QuestionQuestionQuestionQuestion5.5.5.5. ResearchResearchResearchResearch QuestionQuestionQuestionQuestion 6.6.6.6. ResultsResultsResultsResults 7.7.7.7. OngoingOngoingOngoingOngoing WorkWorkWorkWork 8.8.8.8. ConclusionConclusionConclusionConclusion 2
  • 3.
    Anti-patterns are motifsthat are commonly used by developers but they are ineffective and counterproductive in program development and–or maintenance. Opposite to anti-patterns, design patterns are “good” solutions to recurring design problems, conceived to increase reuse, code quality, code readability and, above all, maintainability and resilience tocode readability and, above all, maintainability and resilience to changes. These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies.These motifs evolve and they may have dependencies. 3
  • 4.
    VokacVokacVokacVokac[1][1][1][1] analyzed thecorrective maintenance of a large commercial program, compared the defect rates of classes participating in design motifs against those that did not. Observer and Singleton motifs are correlated with larger classes Classes playing roles in Factory Method were more compact, less coupled, and less defect prone than others classes. No clear tendency exists for Template Method. PietrzakPietrzakPietrzakPietrzak andandandand WalterWalterWalterWalter[2][2][2][2] defined and analyzed the different relationshipsPietrzakPietrzakPietrzakPietrzak andandandand WalterWalterWalterWalter defined and analyzed the different relationships that exist among smells. These relationships presented dependencies between smells and could be exploited to improve the detection tools of anti-patterns. 4 [1] M. Vokac, “Defect frequency and design patterns: An empirical study of industrial code,” IEEE Trans. Softw. Eng., vol. 30, December 2004. [2] B. Pietrzak and B. Walter, “Leveraging code smell detection with inter- smell relations,” Extreme Programming and Agile Processes in Software Engineering, pp. 75–84, 2006.
  • 5.
    Most previous workagree that anti-patterns make the maintenance of systems more difficult and that design patterns can serve as guide in program exploration and, thus, ease maintenance. However, there are no investigation in the literature about the static relationships among anti-patterns and design patterns. Better understand systems by giving knowledge about theBetter understand systems by giving knowledge about the dependencies between what is “good” and what is “bad” in system. Explain the co-existence of such motifs 5
  • 6.
    org.apache.xerces.validators.common.XMLValidator.java r315086 | twl| 1999-11-08 20:10:52 -0500 (Mon, 08 Nov 1999)r315086 | twl | 1999-11-08 20:10:52 -0500 (Mon, 08 Nov 1999) Initial revision org.apache.xerces.validators.dtd.DTDImporter.java r315397 | jeffreyr | 2000-04-04 15:38:39 -0400 (Tue, 04 Apr 2000) Factoring Validators code by Glenn Marcy 6
  • 7.
    We use theDefect DEtection for CORrection Approach (DECOR [3]) to specify and detect anti-patterns. We use the Design Motif Identification Multilayered Approach (DeMIMA [4]) to detect design patterns and static relationships 7 [4] Naouel Moha, Y.-G. Guéhéneuc, L. Duchien, and A.-F. Le Meur, “DECOR: A method for the specification and detection of code and design smells,” Transactions on Software Engineering (TSE), vol. 36, no. 1, 2010. Y.-G. Guéhéneuc and G. Antoniol, “DeMIMA: A multilayered framework for design pattern identification,” Transactions on Software Engineering (TSE), vol. 34, no. 5, pp. 667–684, 2008.
  • 8.
    SystemSystemSystemSystem AntiAntiAntiAnti----patternpatternpatternpattern DesignpatternDesign patternDesign patternDesign pattern StaticStaticStaticStatic relationshiprelationshiprelationshiprelationship ArgoUML ComplexClass Command Use JFreeChart LongMethod Composite Association XercesJ LongParameterList Decorator Agregation MessageChains FactoryMethod CompositionMessageChains FactoryMethod Composition RefusedParentBequest Prototype SpaghettiCode Observer SpeculativeGenerality SwissArmyKnife 8
  • 9.
    Are there staticrelationships between antiAre there static relationships between antiAre there static relationships between antiAre there static relationships between anti---- patternspatternspatternspatterns andandandand designdesigndesigndesign patterns?patterns?patterns?patterns? We assume that a design pattern P has a static relationships with the anti-pattern A if at least one class belonging to P has a use, association, aggregation, or composition relationship with one class belonging to A. 9
  • 10.
  • 11.
  • 12.
  • 13.
    Different anti-patterns canhave different proportions of static relationships with design patterns. The design pattern that often has the most relationships with anti patterns is the Command design pattern. For example, we noted that 50% of static relationships among SpeculativeGenerality and design patterns in ArgoUML, are with the Command motifs. In XercesJ, we observe that 41% of relationships among ClassDataShouldBePrivate was with the Command design pattern. 13
  • 14.
    SpaghettiCodes have nostatic relationships (use, association, aggregation, and composition) with design patterns. SpaghettiCode are revealed by classes with no structure, declaring long methods with no parameters, and using global variables for processing. 14 A SpaghettiCode does not take the advantage of object-orientation mechanisms: polymorphism and inheritance. SpaghettiCodes are difficult to reuse and to maintain.
  • 15.
    The evolution ofrelationships among motifs. 15 Prevent the co-exsitence of anti-patterns and design patterns. Studying the effect of the anti-patterns dependencies on change-proneness. The relation between classes having static dependencies with anti-patterns and fault-proneness. The relation between classes co-changed with anti-patterns and fault- proneness.
  • 16.
    We provide empiricalevidence of the relationships between anti-patterns and design patterns. Some anti-patterns are significantly more likely to have relationships with design patterns than other. We provide a basis for future research to understand the causes and the eventual consequences of these relationships. 16 eventual consequences of these relationships.