ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

50
ARIES: An Eclipse plug-in to Support Extract Class Refactoring Gabriele 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, Crema 19/09/2013 sabato 14 settembre 13

description

During software evolution changes are inevitable. These changes may lead to design erosion and the introduction of inadequate design solutions, such as design antipatterns. Several empirical studies provide evidence that the presence of antipatterns is generally associated with lower productivity, greater rework, and more significant design efforts for developers. In order to improve the quality and remove antipatterns, refactoring operations are needed. In this demo, we present the Extract class features of ARIES (Automated Refactoring In EclipSe), an Eclipse plug-in that supports the software engineer in removing the “Blob” antipattern.

Transcript of ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Page 1: 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

Page 2: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 3: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Refactoring Software SystemsContext

sabato 14 settembre 13

Page 4: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

CohesionCoupling

W. Stevens, G. Myers, and L. Constantine. Structured Design.

IBM Systems Journal, 13(2): 115 - 139, 1974

sabato 14 settembre 13

Page 5: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

sabato 14 settembre 13

Page 6: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 7: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 8: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

sabato 14 settembre 13

Page 9: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

BLOB

sabato 14 settembre 13

Page 10: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 11: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

How?

InputClass C

BLOB

Class C1Output

Class C2

cohesion = 0.2 cohesion = 0.5 cohesion = 0.4

Extract Class Refactoring

sabato 14 settembre 13

Page 12: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 13: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

GRAPH theory-based

sabato 14 settembre 13

Page 14: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

GRAPH theory-basedClass C

BLOBmethod-by-methodmatrix construction

m1 m2 ........ mnm1m2........mn

n methods

sabato 14 settembre 13

Page 15: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 16: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 17: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 18: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 19: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 20: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Metric basedevaluation

sabato 14 settembre 13

Page 21: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

sabato 14 settembre 13

Page 22: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Considered Metrics

sabato 14 settembre 13

Page 23: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Considered Metrics

Lack of Cohesion of Methods (LCOM)The pairs of methods in a class do not sharing any attribute

sabato 14 settembre 13

Page 24: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 25: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 26: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 27: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 28: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 29: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 30: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Evaluation based on historical information

sabato 14 settembre 13

Page 31: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Class1

Class2

Class3

rel1 rel2

Generic Change Refactoring Operation

sabato 14 settembre 13

Page 32: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 33: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 34: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 35: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Developers Evaluation

sabato 14 settembre 13

Page 36: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 37: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

5

4

3

2

1

approach random approach randomGanttProject Xerces

sabato 14 settembre 13

Page 38: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

5

4

3

2

1

approach random approach randomGanttProject Xerces

Average Score4.3

sabato 14 settembre 13

Page 39: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

More qualitative feedback

sabato 14 settembre 13

Page 40: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 41: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

sabato 14 settembre 13

Page 42: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 43: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

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

Page 44: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

MoJoFM between refactorings performed by students and those by the original

developers

93%sabato 14 settembre 13

Page 45: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

sabato 14 settembre 13

Page 46: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

DEMO

sabato 14 settembre 13

Page 47: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Conclusions & Future work

sabato 14 settembre 13

Page 48: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

...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

Page 50: ARIES: An Eclipse Plug-in To Support Extract Class Refactoring

Fabio Palombafabiopalomba13

[email protected]

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