JDeodorant: Clone Refactoring
-
Upload
nikolaos-tsantalis -
Category
Software
-
view
131 -
download
1
Transcript of JDeodorant: Clone Refactoring
ICSE’2016 | Austin | May 19, 2016
Davood Mazinanian Nikolaos Tsantalis
: Clone Refactoring
Raphael Stein Zackary Valenta
1/20
38th International Conference on Software Engineering (ICSE'2016)Formal Tool Demonstration Session
Department of Computer Science and Software EngineeringConcordia University
ICSE’2016 | Austin | May 19, 2016
Clones are harmful
•Error-prone due to inconsistent updates(Juergens et al. @ ICSE’09)
• Increase maintenance effort and cost (Lozano et al. @ ICSM’08)
•Change-prone(Mondal et al. @ ACM SAC’12)
2/20
ICSE’2016 | Austin | May 19, 2016
Clones are good
•Positive impact on maintainability(Kasper & Godfrey @ EMSE’08)
•Less buggyLess effort to fix bugs(Rahman, Bird & Devanbu @ EMSE’12)
3/20
ICSE’2016 | Austin | May 19, 2016
Clone management
Clones that change frequently & are buggy might need some refactoring
4/20
ICSE’2016 | Austin | May 19, 2016
Motivation
Current clone refactoring support is poor
Tairas & Gray (IST’12) studied 1,200 Type-II clones detected in 9 open-source projects:• 10% could be refactored by Eclipse• CeDAR (IST’12) refactored 19%
We need better clone refactoring tools
5/20
ICSE’2016 | Austin | May 19, 2016
Our goal
Help developers:1. Explore clone groups and understand
their relations2. Inspect and understand the differences
between clones
3. Refactor safely the clones
6/20
ICSE’2016 | Austin | May 19, 2016
Clone Group Explorationfeatures
7/20
ICSE’2016 | Austin | May 19, 2016
Clone import
8/20
ICSE’2016 | Austin | May 19, 2016
Subclone information
9/20
ICSE’2016 | Austin | May 19, 2016
Clone filtering
10/20
ICSE’2016 | Austin | May 19, 2016
Clone monitoring
11/20
ICSE’2016 | Austin | May 19, 2016
Clone Pair Visualizationfeatures
12/20
ICSE’2016 | Austin | May 19, 2016
Our approach
common
nesting trees
if (orientation == VERTICAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke());}
if (orientation == VERTICAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke());}else if(orientation == HORIZONTAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke());}
Detected clones
Control StructureMatching
PDGMapping
differences
unmappedstatements
PreconditionExamination
Refactorable clones
13/20
Assessing the Refactorability of Software Clones, IEEE TSE, Nov. 2015
ICSE’2016 | Austin | May 19, 2016
Clone pair visualization
14/20
ICSE’2016 | Austin | May 19, 2016
Semantic tooltips
15/20
ICSE’2016 | Austin | May 19, 2016
Renamed variables
16/20
ICSE’2016 | Austin | May 19, 2016
Clone Pair Refactoringfeatures
17/20
ICSE’2016 | Austin | May 19, 2016
Automatic clone refactoring
Based on the location of the clones, the best refactoring strategy is automatically determined
1. Extract Method (same file)
2. Pull Up Method (common superclass)a) Template Method (clones call local methods)b) Extract Superclass (external common superclass)
3. Introduce Utility Method (static clones)
18/20
ICSE’2016 | Austin | May 19, 2016
Refactoring Preview
19/20
ICSE’2016 | Austin | May 19, 2016
Future work
• Support multi-clone refactoring (>2 clones)
• Explore lambda expressions
• Automated refactoring engine testing
20/20
ICSE’2016 | Austin | May 19, 2016
Visit our project athttp://jdeodorant.org
21/20
ICSE’2016 | Austin | May 19, 2016
Advanced matches
22/20
ICSE’2016 | Austin | May 19, 2016
Advanced matches
23/20