icfca08.ppt

29
Refactorings of Design Defects using Refactorings of Design Defects using Relational Concept Analysis Naouel Moha , Amine Mohamed Rouane Hacene, LORIA, France Petko Valtchev, and Yann-Gaël Guéhéneuc DIRO, University of Montréal, Canada LATECE, Université du Québec à Montréal, Montréal, Canada ICFCA’08 Montréal (Qc), Canada, February 25-28, 2008

Upload: ptidej-team

Post on 06-Dec-2014

169 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: ICFCA08.ppt

Refactorings of Design Defects usingRefactorings of Design Defects using Relational Concept Analysis

Naouel Moha, Amine Mohamed Rouane Hacene,

LORIA, France

Petko Valtchev, and Yann-Gaël Guéhéneuc

DIRO, University of Montréal, CanadaLATECE, Université du Québec à Montréal, Montréal, Canada

ICFCA’08Montréal (Qc), Canada, February 25-28, 2008

Page 2: ICFCA08.ppt

Context

Moha © Refactorings of Design Defects using RCA 2

Page 3: ICFCA08.ppt

Context

Moha © Refactorings of Design Defects using RCA 3

Page 4: ICFCA08.ppt

Context

Moha © Refactorings of Design Defects using RCA 4

Page 5: ICFCA08.ppt

Context: Overall ProcessTextual descriptions

SP

Textual descriptionsof design defects

S1 3

ECIFICA

SUGGESTIA

TION

Rules

ION

RefactoringsRules

DETE

CORRE

Refactorings

2 4

CTION

ECTION

Moha © Refactorings of Design Defects using RCA 5

Classes havingdesign defects

Better Design

Page 6: ICFCA08.ppt

Context: Overall ProcessTextual descriptions

SP

Textual descriptionsof design defects

S1 3

ECIFICA

SUGGESTIA

TION

Rules

ION

RefactoringsRules

DETE

CORRE

Refactorings

2 4

CTION

ECTION

Moha © Refactorings of Design Defects using RCA 6

Classes havingdesign defects

Better Design

Page 7: ICFCA08.ppt

Context: Overall Process

1-2. Specification and Detection of DDsMore and more tools and techniques

Actively researched areaMethod DECOR (Defect dEtection for CORrection) [Moha 06]

3 S ti3. SuggestionManual identification of the modifications

Time-, resource-consuming, error-prone activity, g, p y

4. CorrectionRefactoringsgTechnique used to change “the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior”

Moha © Refactorings of Design Defects using RCA 7

Page 8: ICFCA08.ppt

What Kind of Defects ?

Design Patterns are “good” solutions to recurring design problems

Design Defects (DDs)are “bad” solutions to recurring problems, Antipatterns [Brown 98]

hi d d l t d i t b ki h d thinder development and maintenance by making programs harder to comprehend and/or evolve

DDs of interest: infected by low cohesion and high couplingDDs of interest: infected by low cohesion and high coupling

Cohesion: how closely the methods are related to the variables in the class

Coupling: the degree of its reliance on services provided by other classes

Moha © Refactorings of Design Defects using RCA 8

Page 9: ICFCA08.ppt

What Kind of Defects ?

An example of DDs [Brown 98]

Blob (God Class)

“ Procedural-style design leads to one object with a lion’s share of the responsibilities while most otherobjects only hold data or execute simple processes ”

Large controller class

Many fields and methods with a low cohesion

High coupled with the data stored in associated data classes

Moha © Refactorings of Design Defects using RCA 9

Page 10: ICFCA08.ppt

An Example

Blob

Before

Moha © Refactorings of Design Defects using RCA 10

Page 11: ICFCA08.ppt

An ExampleH t t th d f t ?How to correct the defect ?

Before AfterLarge class becomes less complexLarge and complex class

Moha © Refactorings of Design Defects using RCA 11

Data classes gain more behaviourMore object-oriented style

Small data classesNot object-oriented

Page 12: ICFCA08.ppt

An ExampleR di t ib t l b i ti l ( ith iblRedistribute class members among existing classes (with possibly new classes) to increase cohesion and–or decrease coupling

Before After

Moha © Refactorings of Design Defects using RCA 12

Page 13: ICFCA08.ppt

ContributionSuggestion

RCA [Rouane 07, Ph.D. Thesis]

E i f FCA l i l dExtension of FCA to relational dataModels the inter-object links and infers description logics role likerelations between conceptsRCA provides a suitable framework for clustering individuals along the properties they share and their links with other individualsIdentify methods that share common fields and methods that call common methods cohesive sets low coupled

Moha © Refactorings of Design Defects using RCA 13

Page 14: ICFCA08.ppt

ContributionSuggestion

RCA [Rouane 07, Ph.D. Thesis]

E i f FCA l i l dExtension of FCA to relational dataModels the inter-object links and infers description logics role likerelations between conceptsRCA provides a suitable framework for clustering individuals along the properties they share and their links with other individualsIdentify methods that share common fields and methods that call common methods cohesive sets low coupled

D l t t d h f ti d f t« Develop an automated approach for suggesting defect-correcting refactorings using RCA »

Moha © Refactorings of Design Defects using RCA 14

Page 15: ICFCA08.ppt

An ExampleH t t th d f t ?How to correct the defect ?

Before AfterLarge class becomes less complexLarge and complex class

Moha © Refactorings of Design Defects using RCA 15

Data classes gain more behaviourMore object-oriented style

Small data classesNot object-oriented

Page 16: ICFCA08.ppt

An ExampleH t t th d f t ?How to correct the defect ?

Cohesive SetsBlob

Moha © Refactorings of Design Defects using RCA 16

Page 17: ICFCA08.ppt

An ExampleH t t th d f t ?How to correct the defect ?

I = {W-borrow_date_Book, W-return_date_book}E = {}

I = {call:c4}

I = {‘check_Availability_Book()’}E = {check_Availability_Book()}

E {}

I = {‘reserve_Book()’, W-reserved_book}E = {reserve_Book()}

I = {‘borrow_Book()’}E = {borrow_Book()}

I {call:c4}E = {}

Lattice Cohesive Set

Moha © Refactorings of Design Defects using RCA 17

Page 18: ICFCA08.ppt

An ExampleH t t th d f t ?How to correct the defect ?

Cohesive Sets After Refactoring *

* Move Method Mode Field Create Class

Moha © Refactorings of Design Defects using RCA 18

Move Method, Mode Field, Create Class

Page 19: ICFCA08.ppt

Suggestion

Moha © Refactorings of Design Defects using RCA 19

Page 20: ICFCA08.ppt

Suggestion1. RCF Modeling

Moha © Refactorings of Design Defects using RCA 20

Page 21: ICFCA08.ppt

SuggestionRCA Al ith2. RCA Algorithms

Moha © Refactorings of Design Defects using RCA 21

Page 22: ICFCA08.ppt

SuggestionRCA Al ith2. RCA Algorithms

I = {W-library opened}9 I {W library_opened}E = { }

I = {‘open_Library()’}E = {open Library()}

10

I = {‘close_Library()’}E = {close_Library()}

7E {open_Library()}

Moha © Refactorings of Design Defects using RCA 22

Page 23: ICFCA08.ppt

SuggestionRCA Al ith2. RCA Algorithms

Moha © Refactorings of Design Defects using RCA 23

Page 24: ICFCA08.ppt

SuggestionRCA Al ith2. RCA Algorithms

I = {‘check_Availability_Book()’}E = {check_Availability_Book()}

4

I = {call:c4}E = { }

19

I = {‘reserve_Book()’,W-reserved_book}E = {reserve_Book()}

12I = {‘borrow_Book()’}E = {borrow_Book() }

3

Moha © Refactorings of Design Defects using RCA 24

Page 25: ICFCA08.ppt

Suggestion3. Interpretation

Cohesive Sets After RefactoringCohesive Sets After Refactoring

* Move Method Mode Field Create Class

Moha © Refactorings of Design Defects using RCA 25

Move Method, Mode Field, Create Class

Page 26: ICFCA08.ppt

Experimental Study

ToolingPADL to model source code and generate contextsGalicia to construct and visualize the concept lattices

E i tExperimentsGoal: evaluate the relevance of the cohesive sets suggested4 different open-source programs

Moha © Refactorings of Design Defects using RCA 26

Page 27: ICFCA08.ppt

Experimental Study

PrecisionNb of real cohesive

sets

Nb of cohesive

sets

Nb of fields/methodsmoved

Size (fields + methods)LOCBlob Class

Sys

tem

70%710(27+32) 59(42+66) 1082,049DHTTransportUDPImpl

Azu

reus

V2.

3.0.

6

58%1119(35+62) 97(47+80) 1271,868DHTControlImpl

31%516(24+33) 57(36+47) 831,393TRTrackerBTAnnouncerImpl

55%1731(23+85) 108(29+105)1341,142LogBrokerMonitor

Log4

jV

1.2.

1

50%918(8+44) 52(9+53) 62387Category

50%24(5+30) 35(7+52) 59236IndexReaderene

.4Lu

ce V1 77%1013(24+37) 61(36+48) 84829QueryParser

50%918(17+25) 42(24+35) 59710FSNamesystem

Nut

chV

0.7.

1

73%811(17+18) 35(22+31) 53555JobTracker ( )( )

57%Average Precision:

Moha © Refactorings of Design Defects using RCA 27

Page 28: ICFCA08.ppt

ConclusionContribution

an approach that uses RCA to suggest refactorings to correct certain DDs in particular Blobcertain DDs, in particular Blob

Validation4 different programsRelevant refactorings to improve programs

Future Work- Generalise to other DDs

Assess more programs via our approach- Assess more programs via our approach- Discuss the suggested refactorings with their developers and

apply them

Moha © Refactorings of Design Defects using RCA 28

Page 29: ICFCA08.ppt

QuestionsContact: [email protected]

http://www-etud.iro.umontreal.ca/~mohanaou

Thanks for your attention !

Moha © Refactorings of Design Defects using RCA 29

Thanks for your attention !