jdeodorant: clone refactoring
TRANSCRIPT
![Page 1: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/1.jpg)
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
![Page 2: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/2.jpg)
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
![Page 3: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/3.jpg)
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
![Page 4: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/4.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone management
Clones that change frequently & are buggy might need some refactoring
4/20
![Page 5: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/5.jpg)
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
![Page 6: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/6.jpg)
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
![Page 7: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/7.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone Group Explorationfeatures
7/20
![Page 8: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/8.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone import
8/20
![Page 9: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/9.jpg)
ICSE’2016 | Austin | May 19, 2016
Subclone information
9/20
![Page 10: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/10.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone filtering
10/20
![Page 11: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/11.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone monitoring
11/20
![Page 12: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/12.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone Pair Visualizationfeatures
12/20
![Page 13: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/13.jpg)
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
![Page 14: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/14.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone pair visualization
14/20
![Page 15: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/15.jpg)
ICSE’2016 | Austin | May 19, 2016
Semantic tooltips
15/20
![Page 16: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/16.jpg)
ICSE’2016 | Austin | May 19, 2016
Renamed variables
16/20
![Page 17: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/17.jpg)
ICSE’2016 | Austin | May 19, 2016
Clone Pair Refactoringfeatures
17/20
![Page 18: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/18.jpg)
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
![Page 19: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/19.jpg)
ICSE’2016 | Austin | May 19, 2016
Refactoring Preview
19/20
![Page 20: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/20.jpg)
ICSE’2016 | Austin | May 19, 2016
Future work
• Support multi-clone refactoring (>2 clones)
• Explore lambda expressions
• Automated refactoring engine testing
20/20
![Page 21: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/21.jpg)
ICSE’2016 | Austin | May 19, 2016
Visit our project athttp://jdeodorant.org
21/20
![Page 22: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/22.jpg)
ICSE’2016 | Austin | May 19, 2016
Advanced matches
22/20
![Page 23: JDeodorant: Clone Refactoring](https://reader036.vdocuments.mx/reader036/viewer/2022062310/5870ebae1a28abcf288b6d7f/html5/thumbnails/23.jpg)
ICSE’2016 | Austin | May 19, 2016
Advanced matches
23/20