The document discusses a tool for refactoring clones in software. It aims to help developers explore clone groups, inspect differences between clones, and refactor clones safely. The tool detects clones using control structure matching and program dependence graphs. It visualizes clones and differences and automatically determines the best refactoring strategy, such as extract method or introduce utility method. Future work includes supporting more clones, lambda expressions, and testing refactorings. The tool is intended to improve on poor clone refactoring support in current tools.
1. 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 Engineering
Concordia University
2. 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
3. ICSE’2016 | Austin | May 19, 2016
Clones are good
• Positive impact on maintainability
(Kasper & Godfrey @ EMSE’08)
• Less buggy
Less effort to fix bugs
(Rahman, Bird & Devanbu @ EMSE’12)
3/20
4. ICSE’2016 | Austin | May 19, 2016
Clone management
Clones that change frequently & are buggy
might need some refactoring
4/20
5. 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%
5/20
6. ICSE’2016 | Austin | May 19, 2016
Our goal
Help developers:
1. Explore clone groups and understand
their relations
2. Inspect and understand the differences
between clones
3. Refactor safely the clones
6/20
18. 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
so that we don’t have to apply the same changes multiple times.
The import wizard checks if the clone fragments actually exist in the examined project.
And fixes the clone instances that are syntactically incomplete (e.g., missing closing brackets, incomplete statements)
Group A is a subclone of group B, if every clone instance in A is a subclone (i.e., a partial code fragment) of an instance in B.
Group A is a subclone of group B, if every clone instance in A is a subclone (i.e., a partial code fragment) of an instance in B.
In yellow color, we highlight the differences between matched statements.In red color, we highlight the statements that could not be matched.
In green color we highlight semantically equivalent statements (statement having a different AST structure, but identical functionality)