ppap13a.ppt

16
Fehmi Fehmi Fehmi Fehmi Jaafar Jaafar Jaafar Jaafar , Yann , Yann , Yann , Yann- - -Gaël Gaël Gaël Gaël Guéhéneuc Guéhéneuc Guéhéneuc Guéhéneuc, , , a a an n nd d d S S Sy y yl l lv v vi i ie e e H H Ha a am m me e el l l DIRO, Université de Montréal, QC, Canada 1

Upload: ptidej-team

Post on 28-Nov-2014

275 views

Category:

Technology


0 download

DESCRIPTION

Anti-patterns, design patterns, binary class relationships

TRANSCRIPT

Page 1: Ppap13a.ppt

FehmiFehmiFehmiFehmi JaafarJaafarJaafarJaafar, Yann, Yann, Yann, Yann----Gaël Gaël Gaël Gaël GuéhéneucGuéhéneucGuéhéneucGuéhéneuc,,,, aaaannnndddd SSSSyyyyllllvvvviiiieeee HHHHaaaammmmeeeellll

DIRO, Université de Montréal, QC, Canada

1

Page 2: Ppap13a.ppt

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

Page 3: Ppap13a.ppt

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 to code 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

Page 4: Ppap13a.ppt

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 classesClasses 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 and and and and WalterWalterWalterWalter[2] [2] [2] [2] defined and analyzed the different relationships PietrzakPietrzakPietrzakPietrzak and and and and 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.

Page 5: Ppap13a.ppt

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 the Better 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

Page 6: Ppap13a.ppt

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

Page 7: Ppap13a.ppt

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.

Page 8: Ppap13a.ppt

SystemSystemSystemSystem AntiAntiAntiAnti----patternpatternpatternpattern Design patternDesign patternDesign patternDesign pattern StaticStaticStaticStaticrelationshiprelationshiprelationshiprelationship

ArgoUML ComplexClass Command Use

JFreeChart LongMethod Composite Association

XercesJ LongParameterList Decorator Agregation

MessageChains FactoryMethod CompositionMessageChains FactoryMethod Composition

RefusedParentBequest Prototype

SpaghettiCode Observer

SpeculativeGenerality

SwissArmyKnife

8

Page 9: Ppap13a.ppt

Are there static relationships between antiAre there static relationships between antiAre there static relationships between antiAre there static relationships between anti----patterns patterns patterns patterns and and and and design design design design 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

Page 10: Ppap13a.ppt

10

Page 11: Ppap13a.ppt

11

Page 12: Ppap13a.ppt

12

Page 13: Ppap13a.ppt

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

Page 14: Ppap13a.ppt

SpaghettiCodes have no static relationships (use, association, aggregation, and composition) with design patterns.

SpaghettiCode are revealed by classes with no structure, declaring longmethods 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.

Page 15: Ppap13a.ppt

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.

Page 16: Ppap13a.ppt

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.