ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
-
Upload
fabio-palomba -
Category
Software
-
view
157 -
download
2
description
Transcript of ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
ARIES: An Eclipse plug-in to Support Extract Class RefactoringGabriele Bavota#, Andrea De Lucia*, Andrian Marcus❊
Rocco Oliveto✢, Fabio Palomba*, Michele Tufano*
*University of Salerno, Italy❊Wayne State University, USA✢University of Molise, Italy
#University of Sannio, Italy
8th Italian Workshop on Eclipse Technologies, Crema19/09/2013
sabato 14 settembre 13
Refactoring Software Systems: why?
Extract Class Refactoring
ARIES: Automated Refactoring In EclipSe
A Graph-theory based method for Extract Class Refactoring
Context
ClassClass
Class
Supporting Extract Class Refactoring in Eclipse
sabato 14 settembre 13
Refactoring Software SystemsContext
sabato 14 settembre 13
CohesionCoupling
W. Stevens, G. Myers, and L. Constantine. Structured Design.
IBM Systems Journal, 13(2): 115 - 139, 1974
sabato 14 settembre 13
sabato 14 settembre 13
Tibor Gyimóthy, Rudolf Ferenc, and István Siket. Empirical validation of object-oriented metrics on open source software for fault prediction. IEEE Transactions on Software Engineering (TSE), 2005.
M. Abbes, F. Khomh, Y.-G. Guéhéneuc, and G. Antoniol. An empirical study of the impact of two antipatterns, blob and spaghetti code, on program comprehension. European Conference on Software Maintenance and Reengineering, CSMR 2011.
L. C. Briand, J. Wüst, J. W. Daly, and V. D. Porter. Exploring the relationship between design measures and software quality in object- oriented systems. Journal of Systems and Software (JSS), 2000.
Restructuring... why?ProducvyCompnsibily# Defect
sabato 14 settembre 13
Refactoring is...“Refactoring is a disciplined technique for restructuring an
existing body of code, improving its non-functional attributes without changing its external behavior.”
sabato 14 settembre 13
sabato 14 settembre 13
BLOB
sabato 14 settembre 13
Splitting a class having many responsibilities into different classes
InputClass C
BLOB
Class C1Output
Class C2
cohesion = 0.2 cohesion = 0.5 cohesion = 0.4
Extract Class Refactoring
sabato 14 settembre 13
How?
InputClass C
BLOB
Class C1Output
Class C2
cohesion = 0.2 cohesion = 0.5 cohesion = 0.4
Extract Class Refactoring
sabato 14 settembre 13
ClassClass
Class
A Graph-theory based method for Extract Class Refactoring
G. Bavota, A. De Lucia, A. Marcus, and R. Oliveto.Automating Extract Class Refactoring: an Improved Method and its Evaluation.
Empirical Software Engineering (EMSE), 2013
sabato 14 settembre 13
GRAPH theory-based
sabato 14 settembre 13
GRAPH theory-basedClass C
BLOBmethod-by-methodmatrix construction
m1 m2 ........ mnm1m2........mn
n methods
sabato 14 settembre 13
GRAPH theory-basedClass C
BLOBmethod-by-methodmatrix construction
m1 m2 ........ mnm1m2........mn
SSM CIM CSMStructural Similarity
between MethodsCall-based Interaction
between MethodsConceptual Similarity
between Methods
n methods
sabato 14 settembre 13
GRAPH theory-basedClass C
BLOBmethod-by-methodmatrix construction
m1 m2 ........ mnm1m2........mn
SSM CIM CSMStructural Similarity
between MethodsCall-based Interaction
between MethodsConceptual Similarity
between Methods
n methods
ci,j = wSSM · SSM + wCIM · CIM + wCSM · CSM
sabato 14 settembre 13
GRAPH theory-basedm1 m2 ........ mn
m1m2........mn
method-by-method matrixfiltering and transitive closure
0.8
0.70.5
0.70.6
Chain 1
Chain 2Chain 3
sabato 14 settembre 13
GRAPH theory-basedm1 m2 ........ mn
m1m2........mn
method-by-method matrixfiltering and transitive closure
0.8
0.70.5
0.70.6
Chain 1
Chain 2Chain 3
sabato 14 settembre 13
GRAPH theory-basedm1 m2 ........ mn
m1m2........mn
method-by-method matrixfiltering and transitive closure
0.8
0.70.5
0.70.6
Chain 1
Chain 2Chain 3
0.8
0.70.5
0.70.6
Chain 1
Chain 2Chain 3
merging trivialchains
Chain 1
Candidate Class 1
Chain 2Chain 3
Candidate Class 2
sabato 14 settembre 13
Metric basedevaluation
sabato 14 settembre 13
sabato 14 settembre 13
Considered Metrics
sabato 14 settembre 13
Considered Metrics
Lack of Cohesion of Methods (LCOM)The pairs of methods in a class do not sharing any attribute
sabato 14 settembre 13
Considered Metrics
Lack of Cohesion of Methods (LCOM)The pairs of methods in a class do not sharing any attributeConceptual Cohesion of Classes (C3)Semantic similarity between methods of a class
sabato 14 settembre 13
Considered Metrics
Lack of Cohesion of Methods (LCOM)The pairs of methods in a class do not sharing any attributeConceptual Cohesion of Classes (C3)Semantic similarity between methods of a classMessage Passing Coupling (MPC)The number of calls between a pair of classes
sabato 14 settembre 13
Considered Metrics
Lack of Cohesion of Methods (LCOM)
Conceptual Cohesion of Classes (C3)
Message Passing Coupling (MPC)
The pairs of methods in a class do not sharing any attribute
Semantic similarity between methods of a class
The number of calls between a pair of classes
sabato 14 settembre 13
Considered Metrics
+82%Lack of Cohesion of Methods (LCOM)
Conceptual Cohesion of Classes (C3)
Message Passing Coupling (MPC)
The pairs of methods in a class do not sharing any attribute
Semantic similarity between methods of a class
The number of calls between a pair of classes
sabato 14 settembre 13
Considered Metrics
+82%+105%
Lack of Cohesion of Methods (LCOM)
Conceptual Cohesion of Classes (C3)
Message Passing Coupling (MPC)
The pairs of methods in a class do not sharing any attribute
Semantic similarity between methods of a class
The number of calls between a pair of classes
sabato 14 settembre 13
Considered Metrics
+82%+105%+3%
Lack of Cohesion of Methods (LCOM)
Conceptual Cohesion of Classes (C3)
Message Passing Coupling (MPC)
The pairs of methods in a class do not sharing any attribute
Semantic similarity between methods of a class
The number of calls between a pair of classes
sabato 14 settembre 13
Evaluation based on historical information
sabato 14 settembre 13
Class1
Class2
Class3
rel1 rel2
Generic Change Refactoring Operation
sabato 14 settembre 13
Class1
Class2
Class3
rel1 rel2
Generic Change Refactoring Operation
Class 1 rel1Class 1 rel2
Rename Field
Class 2 rel1Class 2, Class 3 rel2
Extract Class
sabato 14 settembre 13
System Original Class Extracted Classes
Apache HSQLDB
Database (41) Database (27)
Apache HSQLDB
Database (41)SchemaManager(14)
Apache HSQLDB Select (14) Select (7)Apache HSQLDB Select (14)Result (7)
Apache HSQLDB
UserManager (13) UserManager (10)
Apache HSQLDB
UserManager (13)GranteeManager (3)
ArgoUMLFileGeneratorAdapter (9) FileGeneratorAdapter (3)
ArgoUMLFileGeneratorAdapter (9)
TempFileUtils (6)ArgoUMLImport (10) Import (7)
ArgoUMLImport (10)
ImportCommon (3)
JEdit JEditTextArea (214)JEditTextArea (22)
JEdit JEditTextArea (214) SelectionManager (11)JEdit JEditTextArea (214)TextArea (181)
JFreeChartJFreeChart (24) JFreeChart (16)
JFreeChartJFreeChart (24)
Plot (8)JFreeChartNumberAxis (20) NumberAxis (16)
JFreeChartNumberAxis (20)
ValueAxis (4)
JHotDraw DefaultApplicationModel (14) DefaultApplicationModel (4)JHotDraw DefaultApplicationModel (14)AbstractApplicationModel (10)
XercesXMLDTDValidator (69) XMLDTDValidator (38)
XercesXMLDTDValidator (69)
XMLDTDProcessor (31)XercesXMLSerializer (25) XMLSerializer (12)
XercesXMLSerializer (25)
DOMWriterImpl (13)sabato 14 settembre 13
Class MoJoFMDatabase (41) 97%
Select (14) 83%
UserManager (13) 93%
FileGeneratorAdapter (9) 86%
Import (10) 100%
JEditTextArea (214) 84%
JFreeChart (24) 95%
NumberAxis (20) 94%
DefaultApplicationModel (14) 92%
XMLDTDValidator (69) 88%
XMLSerializer (25) 91%
Average 91%
sabato 14 settembre 13
Developers Evaluation
sabato 14 settembre 13
Subjects50 Master’s students
Meaningfulness of the suggested refactoring operations
Objects17 Blobs used in the metric-based evaluation
What we askedAgreement to the claim: “The proposed refactoring results in a better division of responsibilities”
Five point Likert scale: “1: Strongly disagree; 2: Disagree; 3: Neutral; 4: Agree; 5: Fully agree”
sabato 14 settembre 13
5
4
3
2
1
approach random approach randomGanttProject Xerces
sabato 14 settembre 13
5
4
3
2
1
approach random approach randomGanttProject Xerces
Average Score4.3
sabato 14 settembre 13
More qualitative feedback
sabato 14 settembre 13
Subjects15 Master’s students
Objects11 Blobs refactored by original developers
What we askedWould you split this class?
if YES:i. Why? ii. Would you split the class differently than the provided refactoring solution? Why? iii. Did you find the provided refactoring solution useful as starting point to perform your refactoring? Why?
if NO:i. Why?:
sabato 14 settembre 13
sabato 14 settembre 13
Usefulness of the provided refactoring1. it eases code comprehension; 2. it highlights the main responsibilities implemented in a class; 3. the extracted classes are cohesive.
sabato 14 settembre 13
Usefulness of the provided refactoring1. it eases code comprehension; 2. it highlights the main responsibilities implemented in a class; 3. the extracted classes are cohesive.
“without the refactoring suggestion it would be too difficult to identify the main responsibilities of the classes”
sabato 14 settembre 13
MoJoFM between refactorings performed by students and those by the original
developers
93%sabato 14 settembre 13
sabato 14 settembre 13
DEMO
sabato 14 settembre 13
Conclusions & Future work
sabato 14 settembre 13
...conclusion...
G. Bavota, A. De Lucia, A. Marcus, R. Oliveto, and F. Palomba. Supporting Extract Class Refactoring in Eclipse: The ARIES Project.
In Proceedings of the 34th International Conference on Software Engineering (ICSE 2012), Zurich, Switzerland, 2012. IEEE Press. Formal Tool Demo. pp. 1419-1422
sabato 14 settembre 13
...future work...
implement other refactoring operations,and more sophisticated approaches to detect Blobs
release ARIES asaphttp://www.dmi.unisa.it/people/bavota/www/pages/projects.html
Dec
1
sabato 14 settembre 13
Fabio Palombafabiopalomba13
http://www.linkedin.com/pub/fabio-palomba/4a/542/60
Thank you!Questions and/or comments
ARIES: An Eclipse plug-in to Support Extract Class Refactoring
University of Salerno
sabato 14 settembre 13