SlideShare a Scribd company logo
Clone images created by Rebecca Tiarks et al.

Unification and Refactoring
of Clones
Giri Panamoottil Krishnan and Nikolaos Tsantalis
Department of Computer Science & Software Engineering
Motivation
• Clones may be harmful
– Clones are associated with error-proneness due to
inconsistent updates (Juergens et al. @ ICSE’09)
– Clones increase significantly the maintenance effort
and cost (Lozano et al. @ ICSM’08)
– Clones are change-prone (Mondal et al. 2012)

• Some studies have shown that clones are stable

IEEE CSMR-WCRE 2014 Software Evolution Week

2
Motivation cont'd
Current refactoring tools perform poorly
A study by Tairas & Gray [IST’12] on Type-II clones
detected by Deckard in 9 open-source projects
revealed:
– only 10.6% of them could be refactored by Eclipse
– CeDAR [IST’12] was able to refactor 18.7% of them

IEEE CSMR-WCRE 2014 Software Evolution Week

3
Limitation #1
Current tools can parameterize only a small
subset of differences in clones.
– Mostly differences between variable identifiers,
literals, simple method calls.

Clone #1

Clone #2

Rectangle rectangle = new Rectangle(
a, b, c, high – low );

Rectangle rectangle = new Rectangle(
a, b, c, getHeight() );

IEEE CSMR-WCRE 2014 Software Evolution Week

4
Limitation #2
Current approaches may return non-optimal
matching solutions.
– They do not explore the entire search space of
possible matches.
– In case of multiple possible matches, they select
the “first” or “best” match.
– They face scalability issues due to the problem of
combinatorial explosion.

IEEE CSMR-WCRE 2014 Software Evolution Week

5
Clone #2

Clone #1
if (orientation == VERTICAL) {
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
else if (orientation == HORIZONTAL) {
Line2D line = new Line2D.Double();
double x0 = dataArea.getMinX();
double x1 = dataArea.getMaxX();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}

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 (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}
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());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}

NOT
APPROVED

IEEE CSMR-WCRE 2014 Software Evolution Week

6
Clone #1
if (orientation == VERTICAL) {
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
else if (orientation == HORIZONTAL) {
Line2D line = new Line2D.Double();
double x0 = dataArea.getMinX();
double x1 = dataArea.getMaxX();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}

Clone #2
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 (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}
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());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}

IEEE CSMR-WCRE 2014 Software Evolution Week

7
Clone #2

Clone #1
if (orientation == VERTICAL) {
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
else if (orientation == HORIZONTAL) {
Line2D line = new Line2D.Double();
double x0 = dataArea.getMinX();
double x1 = dataArea.getMaxX();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}

if (orientation == HORIZONTAL) {
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
else 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 (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}

APPROVED

IEEE CSMR-WCRE 2014 Software Evolution Week

8
Minimizing differences
• Minimizing the differences during the matching
process is critical for refactoring.
• Why?
– Less differences means less parameters for the extracted
method (i.e., a more reusable method).
– Less differences means also lower probability for
precondition violations (i.e., higher refactoring feasibility)

• Matching process objectives:
– Maximize the number of matched statements
– Minimize the number of differences between them
IEEE CSMR-WCRE 2014 Software Evolution Week

9
Limitation #3
There are no preconditions to determine
whether clones can be safely refactored.
– The parameterization of differences might change
the behavior of the program.
– Statements in gaps need to be moved before the
cloned code. Changing the order of statements
might also affect the behavior of the program.

IEEE CSMR-WCRE 2014 Software Evolution Week

10
Our goal
Improve the state-of-the-art in the Refactoring of
Software Clones:
Given two code fragments containing clones;
Find potential control structures that can be refactored.
Find an optimal mapping between the statements of
two clones.
Make sure that the refactoring of the clones will
preserve program behavior.
Find the most appropriate refactoring strategy to
eliminate the clones.
IEEE CSMR-WCRE 2014 Software Evolution Week

11
Our approach
Detected clones

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());
}

Refactorable clones

isomorphic

differences

CDT pairs

unmapped
statements

Control Structure
Matching

PDG
Mapping

Precondition
Examination

IEEE CSMR-WCRE 2014 Software Evolution Week

12
Phase 1: Control Structure Matching
• Intuition: two pieces of code can be merged only
if they have an identical control structure.
• We extract the Control Dependence Trees (CDTs)
representing the control structure of the input
methods or clones.
• We find all non-overlapping largest common
subtrees within the CDTs.
• Each subtree match will be treated as a separate
refactoring opportunity.
IEEE CSMR-WCRE 2014 Software Evolution Week

13
CDT Subtree Matching
CDT of Fragment #1

CDT of Fragment #2
x

A

a

B

D

C

E

F

y

b

G

f

c

g

d

IEEE CSMR-WCRE 2014 Software Evolution Week

e

14
Phase 2: PDG Mapping
• We extract the PDG subgraphs corresponding to
the matched CDT subtrees.
• We want to find the common subgraph that
satisfies two conditions:
– It has the maximum number of matched nodes
– The matched nodes have the minimum number of
differences.

• This is an optimization problem that can be
solved using an adaptation of a Maximum
Common Subgraph algorithm [McGregor, 1982].
IEEE CSMR-WCRE 2014 Software Evolution Week

15
MCS Algorithm
Builds a search tree in depth-first order, where
each node represents a state of the search space.
Explores the entire search space.
It has an exponential worst case complexity.
As the number of possible matching node
combinations increases, the width of the search
tree grows rapidly (combinatorial explosion).

IEEE CSMR-WCRE 2014 Software Evolution Week

16
Divide-and-Conquer
• We break the original matching problem into
smaller sub-problems based on the control
dependence structure of the clones.
• Finally, we combine the sub-solutions to give
a global solution to the original matching
problem.

IEEE CSMR-WCRE 2014 Software Evolution Week

17
Bottom-up Divide-and-Conquer
CDT subtree of Clone #1

CDT subtree of Clone #2

A

a

B

Level 2

D

C

E

F

b

G

f

c

g

IEEE CSMR-WCRE 2014 Software Evolution Week

d

e

18
Bottom-up Divide-and-Conquer
CDT subtree of Clone #1

CDT subtree of Clone #2

A

a

B

Level 2

C

E

F

b

G

f

c

g

IEEE CSMR-WCRE 2014 Software Evolution Week

e

19
Phase 3: Precondition examination
• Preconditions related to clone differences:
– Parameterization of differences should not break
existing data dependences in the PDGs.
– Reordering of unmapped statements should not
break existing data dependences in the PDGs.

• Preconditions related to method extraction:
– The unified code should return one variable at most.
– Matched branching (break, continue) statements
should be accompanied with the corresponding
matched loops in the unified code.
IEEE CSMR-WCRE 2014 Software Evolution Week

20
Evaluation
• We compared our approach with a state-ofthe-art tool in the refactoring of Type-II clones,
CeDAR [Tairas & Gray, IST’12].
• 2342 clone groups, detected in 7 open-source
projects by Deckard clone detection tool.
• CeDAR is able to analyze only clone groups in
which all clones belong to the same Java file.

IEEE CSMR-WCRE 2014 Software Evolution Week

21
Clone groups within the same Java file
Project

Clone
groups

Eclipse

CeDAR

JDeodorant



Ant 1.7.0

120

14

12%

28

23%

50

42%

+79%

Columba 1.4

88

13

15%

30

34%

41

47%

+37%

EMF 2.4.1

149

8

5%

14

9%

54

36%

+286%

JMeter 2.3.2

68

3

4%

11

16%

20

29%

+82%

JEdit 4.2

157

15

10%

20

13%

57

36%

+185%

JFreeChart 1.0.10

291

29

10%

62

21%

87

30%

+40%

JRuby 1.4.0

81

23

28%

23

28%

35

43%

+52%

Total

954

105

11%

188

20%

344

36%

+83%

IEEE CSMR-WCRE 2014 Software Evolution Week

22
Clone groups within different Java files
Project

Clone
groups

JDeodorant

Ant 1.7.0

211

42

20%

Columba 1.4

275

66

24%

EMF 2.4.1

58

12

21%

JMeter 2.3.2

225

68

30%

JEdit 4.2

101

21

21%

JFreeChart 1.0.10

337

121

36%

JRuby 1.4.0

181

43

24%

Total

1388

373

27%

IEEE CSMR-WCRE 2014 Software Evolution Week

23
Conclusions
• Our approach was able to refactor 83% more
clone groups than CeDAR.
• Our approach assessed as refactorable 27% of
the clones groups, in which clones are placed in
different files.
• The study revealed that 36% of the clone
groups can be refactored directly or in the form
of sub-clones.
IEEE CSMR-WCRE 2014 Software Evolution Week

24
Visit our project at
IEEE CSMR-WCRE 2014 Software Evolution Week

25

More Related Content

What's hot

Matematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhanaMatematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhana
lia170494
 
Tut 1
Tut 1Tut 1
Tut 1
Arun Sethi
 
Lesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationLesson 11: Implicit Differentiation
Lesson 11: Implicit Differentiation
Matthew Leingang
 
Nts
NtsNts
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
openGl example
openGl exampleopenGl example
openGl example
Brian Goggins
 
Elementos finitos
Elementos finitosElementos finitos
Elementos finitos
jd
 
Introduction to CNN with Application to Object Recognition
Introduction to CNN with Application to Object RecognitionIntroduction to CNN with Application to Object Recognition
Introduction to CNN with Application to Object Recognition
Artifacia
 
Grid help, Processing
Grid help, ProcessingGrid help, Processing
Grid help, Processing
Christian Gwiozda
 
DeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep LearningDeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep Learning
Masahiro Sakai
 
Ese563
Ese563 Ese563
Ese563
Azlin lolin
 
FEM Introduction: Solving ODE-BVP using the Galerkin's Method
FEM Introduction: Solving ODE-BVP using the Galerkin's MethodFEM Introduction: Solving ODE-BVP using the Galerkin's Method
FEM Introduction: Solving ODE-BVP using the Galerkin's Method
Suddhasheel GHOSH, PhD
 
πιασαμε τα ορια
πιασαμε τα ορια πιασαμε τα ορια
πιασαμε τα ορια
Μαυρουδης Μακης
 
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
The Statistical and Applied Mathematical Sciences Institute
 
Solve ODE - BVP through the Least Squares Method
Solve ODE - BVP through the Least Squares MethodSolve ODE - BVP through the Least Squares Method
Solve ODE - BVP through the Least Squares Method
Suddhasheel GHOSH, PhD
 
Image Cryptography and Steganography
Image Cryptography and SteganographyImage Cryptography and Steganography
Image Cryptography and Steganography
Mohammad Amin Amjadi
 
C programs
C programsC programs
C programs
Azaj Khan
 
Integrated exercise a_(book_2_B)_Ans
Integrated exercise a_(book_2_B)_AnsIntegrated exercise a_(book_2_B)_Ans
Integrated exercise a_(book_2_B)_Ans
ken1470
 
Numerical Methods Solving Linear Equations
Numerical Methods Solving Linear EquationsNumerical Methods Solving Linear Equations
Research: Automatic Diabetic Retinopathy Detection
Research: Automatic Diabetic Retinopathy DetectionResearch: Automatic Diabetic Retinopathy Detection
Research: Automatic Diabetic Retinopathy Detection
Madhawa Gunasekara
 

What's hot (20)

Matematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhanaMatematika Ekonomi Diferensiasi fungsi sederhana
Matematika Ekonomi Diferensiasi fungsi sederhana
 
Tut 1
Tut 1Tut 1
Tut 1
 
Lesson 11: Implicit Differentiation
Lesson 11: Implicit DifferentiationLesson 11: Implicit Differentiation
Lesson 11: Implicit Differentiation
 
Nts
NtsNts
Nts
 
Basic m4-2-chapter1
Basic m4-2-chapter1Basic m4-2-chapter1
Basic m4-2-chapter1
 
openGl example
openGl exampleopenGl example
openGl example
 
Elementos finitos
Elementos finitosElementos finitos
Elementos finitos
 
Introduction to CNN with Application to Object Recognition
Introduction to CNN with Application to Object RecognitionIntroduction to CNN with Application to Object Recognition
Introduction to CNN with Application to Object Recognition
 
Grid help, Processing
Grid help, ProcessingGrid help, Processing
Grid help, Processing
 
DeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep LearningDeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep Learning
 
Ese563
Ese563 Ese563
Ese563
 
FEM Introduction: Solving ODE-BVP using the Galerkin's Method
FEM Introduction: Solving ODE-BVP using the Galerkin's MethodFEM Introduction: Solving ODE-BVP using the Galerkin's Method
FEM Introduction: Solving ODE-BVP using the Galerkin's Method
 
πιασαμε τα ορια
πιασαμε τα ορια πιασαμε τα ορια
πιασαμε τα ορια
 
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
QMC: Operator Splitting Workshop, Structured Decomposition of Multi-view Data...
 
Solve ODE - BVP through the Least Squares Method
Solve ODE - BVP through the Least Squares MethodSolve ODE - BVP through the Least Squares Method
Solve ODE - BVP through the Least Squares Method
 
Image Cryptography and Steganography
Image Cryptography and SteganographyImage Cryptography and Steganography
Image Cryptography and Steganography
 
C programs
C programsC programs
C programs
 
Integrated exercise a_(book_2_B)_Ans
Integrated exercise a_(book_2_B)_AnsIntegrated exercise a_(book_2_B)_Ans
Integrated exercise a_(book_2_B)_Ans
 
Numerical Methods Solving Linear Equations
Numerical Methods Solving Linear EquationsNumerical Methods Solving Linear Equations
Numerical Methods Solving Linear Equations
 
Research: Automatic Diabetic Retinopathy Detection
Research: Automatic Diabetic Retinopathy DetectionResearch: Automatic Diabetic Retinopathy Detection
Research: Automatic Diabetic Retinopathy Detection
 

Similar to Unification and Refactoring of Clones

import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
anyacarpets
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]
Palak Sanghani
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
theijes
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
honjo2
 
Cy33602608
Cy33602608Cy33602608
Cy33602608
IJERA Editor
 
Cy33602608
Cy33602608Cy33602608
Cy33602608
IJERA Editor
 
Abstract
AbstractAbstract
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
Jenchoke Tachagomain
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
Jenchoke Tachagomain
 
Listing for CircleFunctions
Listing for CircleFunctionsListing for CircleFunctions
Listing for CircleFunctions
Derek Dhammaloka
 
Observations on Ternary Quadratic Equation z2 = 82x2 +y2
Observations on Ternary Quadratic Equation z2 = 82x2 +y2Observations on Ternary Quadratic Equation z2 = 82x2 +y2
Observations on Ternary Quadratic Equation z2 = 82x2 +y2
IRJET Journal
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
kinan keshkeh
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
forladies
 
Elastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programmingElastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programming
Salar Delavar Qashqai
 
Design Patterns in .Net
Design Patterns in .NetDesign Patterns in .Net
Design Patterns in .Net
Dmitri Nesteruk
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
Amit Kapoor
 
The graph above is just an example that shows the differences in dis.pdf
The graph above is just an example that shows the differences in dis.pdfThe graph above is just an example that shows the differences in dis.pdf
The graph above is just an example that shows the differences in dis.pdf
jyothimuppasani1
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
NAVYA RAO
 

Similar to Unification and Refactoring of Clones (20)

import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]
 
The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)The International Journal of Engineering and Science (IJES)
The International Journal of Engineering and Science (IJES)
 
Mashup caravan android-talks
Mashup caravan android-talksMashup caravan android-talks
Mashup caravan android-talks
 
Cy33602608
Cy33602608Cy33602608
Cy33602608
 
Cy33602608
Cy33602608Cy33602608
Cy33602608
 
Abstract
AbstractAbstract
Abstract
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Mobile Game and Application with J2ME - Collision Detection
Mobile Gameand Application withJ2ME  - Collision DetectionMobile Gameand Application withJ2ME  - Collision Detection
Mobile Game and Application with J2ME - Collision Detection
 
Mobile Game and Application with J2ME
Mobile Gameand Application with J2MEMobile Gameand Application with J2ME
Mobile Game and Application with J2ME
 
Listing for CircleFunctions
Listing for CircleFunctionsListing for CircleFunctions
Listing for CircleFunctions
 
Observations on Ternary Quadratic Equation z2 = 82x2 +y2
Observations on Ternary Quadratic Equation z2 = 82x2 +y2Observations on Ternary Quadratic Equation z2 = 82x2 +y2
Observations on Ternary Quadratic Equation z2 = 82x2 +y2
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
 
Elastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programmingElastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programming
 
Design Patterns in .Net
Design Patterns in .NetDesign Patterns in .Net
Design Patterns in .Net
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
The graph above is just an example that shows the differences in dis.pdf
The graph above is just an example that shows the differences in dis.pdfThe graph above is just an example that shows the differences in dis.pdf
The graph above is just an example that shows the differences in dis.pdf
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
 

More from Nikolaos Tsantalis

Refactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolutionRefactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolution
Nikolaos Tsantalis
 
CASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award TalkCASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award Talk
Nikolaos Tsantalis
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper Talk
Nikolaos Tsantalis
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit History
Nikolaos Tsantalis
 
Clone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsClone Refactoring with Lambda Expressions
Clone Refactoring with Lambda Expressions
Nikolaos Tsantalis
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub Contributors
Nikolaos Tsantalis
 
Migrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsMigrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessors
Nikolaos Tsantalis
 
JDeodorant: Clone Refactoring
JDeodorant: Clone RefactoringJDeodorant: Clone Refactoring
JDeodorant: Clone Refactoring
Nikolaos Tsantalis
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessors
Nikolaos Tsantalis
 
An Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS PreprocessorsAn Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS Preprocessors
Nikolaos Tsantalis
 
Improving the Unification of Software Clones Using Tree and Graph Matching Al...
Improving the Unification of Software Clones Using Tree and Graph Matching Al...Improving the Unification of Software Clones Using Tree and Graph Matching Al...
Improving the Unification of Software Clones Using Tree and Graph Matching Al...
Nikolaos Tsantalis
 
Code Smell Research: History and Future Directions
Code Smell Research: History and Future DirectionsCode Smell Research: History and Future Directions
Code Smell Research: History and Future Directions
Nikolaos Tsantalis
 
Preventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the FuturePreventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the Future
Nikolaos Tsantalis
 
An Empirical Study of Duplication in Cascading Style Sheets
An Empirical Study of Duplication in Cascading Style SheetsAn Empirical Study of Duplication in Cascading Style Sheets
An Empirical Study of Duplication in Cascading Style Sheets
Nikolaos Tsantalis
 
Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical Volatility
Nikolaos Tsantalis
 
Feature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web ApplicationsFeature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web Applications
Nikolaos Tsantalis
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring Activity
Nikolaos Tsantalis
 

More from Nikolaos Tsantalis (17)

Refactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolutionRefactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolution
 
CASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award TalkCASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award Talk
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper Talk
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit History
 
Clone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsClone Refactoring with Lambda Expressions
Clone Refactoring with Lambda Expressions
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub Contributors
 
Migrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsMigrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessors
 
JDeodorant: Clone Refactoring
JDeodorant: Clone RefactoringJDeodorant: Clone Refactoring
JDeodorant: Clone Refactoring
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessors
 
An Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS PreprocessorsAn Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS Preprocessors
 
Improving the Unification of Software Clones Using Tree and Graph Matching Al...
Improving the Unification of Software Clones Using Tree and Graph Matching Al...Improving the Unification of Software Clones Using Tree and Graph Matching Al...
Improving the Unification of Software Clones Using Tree and Graph Matching Al...
 
Code Smell Research: History and Future Directions
Code Smell Research: History and Future DirectionsCode Smell Research: History and Future Directions
Code Smell Research: History and Future Directions
 
Preventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the FuturePreventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the Future
 
An Empirical Study of Duplication in Cascading Style Sheets
An Empirical Study of Duplication in Cascading Style SheetsAn Empirical Study of Duplication in Cascading Style Sheets
An Empirical Study of Duplication in Cascading Style Sheets
 
Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical Volatility
 
Feature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web ApplicationsFeature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web Applications
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring Activity
 

Recently uploaded

Farming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptxFarming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptx
Frédéric Baudron
 
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
PsychoTech Services
 
Gadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdfGadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdf
PirithiRaju
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
LengamoLAppostilic
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
vluwdy49
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
Sérgio Sacani
 
Sciences of Europe journal No 142 (2024)
Sciences of Europe journal No 142 (2024)Sciences of Europe journal No 142 (2024)
Sciences of Europe journal No 142 (2024)
Sciences of Europe
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
Aditi Bajpai
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
Scintica Instrumentation
 
Compexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titrationCompexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titration
Vandana Devesh Sharma
 
23PH301 - Optics - Optical Lenses.pptx
23PH301 - Optics  -  Optical Lenses.pptx23PH301 - Optics  -  Optical Lenses.pptx
23PH301 - Optics - Optical Lenses.pptx
RDhivya6
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
Sérgio Sacani
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
by6843629
 
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
hozt8xgk
 
Randomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNERandomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNE
University of Maribor
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
İsa Badur
 
Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
Leonel Morgado
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
Leonel Morgado
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
PirithiRaju
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
RitabrataSarkar3
 

Recently uploaded (20)

Farming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptxFarming systems analysis: what have we learnt?.pptx
Farming systems analysis: what have we learnt?.pptx
 
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
 
Gadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdfGadgets for management of stored product pests_Dr.UPR.pdf
Gadgets for management of stored product pests_Dr.UPR.pdf
 
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdfwaterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
waterlessdyeingtechnolgyusing carbon dioxide chemicalspdf
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
 
Sciences of Europe journal No 142 (2024)
Sciences of Europe journal No 142 (2024)Sciences of Europe journal No 142 (2024)
Sciences of Europe journal No 142 (2024)
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
 
Compexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titrationCompexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titration
 
23PH301 - Optics - Optical Lenses.pptx
23PH301 - Optics  -  Optical Lenses.pptx23PH301 - Optics  -  Optical Lenses.pptx
23PH301 - Optics - Optical Lenses.pptx
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
 
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
快速办理(UAM毕业证书)马德里自治大学毕业证学位证一模一样
 
Randomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNERandomised Optimisation Algorithms in DAPHNE
Randomised Optimisation Algorithms in DAPHNE
 
aziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobelaziz sancar nobel prize winner: from mardin to nobel
aziz sancar nobel prize winner: from mardin to nobel
 
Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
 

Unification and Refactoring of Clones

  • 1. Clone images created by Rebecca Tiarks et al. Unification and Refactoring of Clones Giri Panamoottil Krishnan and Nikolaos Tsantalis Department of Computer Science & Software Engineering
  • 2. Motivation • Clones may be harmful – Clones are associated with error-proneness due to inconsistent updates (Juergens et al. @ ICSE’09) – Clones increase significantly the maintenance effort and cost (Lozano et al. @ ICSM’08) – Clones are change-prone (Mondal et al. 2012) • Some studies have shown that clones are stable IEEE CSMR-WCRE 2014 Software Evolution Week 2
  • 3. Motivation cont'd Current refactoring tools perform poorly A study by Tairas & Gray [IST’12] on Type-II clones detected by Deckard in 9 open-source projects revealed: – only 10.6% of them could be refactored by Eclipse – CeDAR [IST’12] was able to refactor 18.7% of them IEEE CSMR-WCRE 2014 Software Evolution Week 3
  • 4. Limitation #1 Current tools can parameterize only a small subset of differences in clones. – Mostly differences between variable identifiers, literals, simple method calls. Clone #1 Clone #2 Rectangle rectangle = new Rectangle( a, b, c, high – low ); Rectangle rectangle = new Rectangle( a, b, c, getHeight() ); IEEE CSMR-WCRE 2014 Software Evolution Week 4
  • 5. Limitation #2 Current approaches may return non-optimal matching solutions. – They do not explore the entire search space of possible matches. – In case of multiple possible matches, they select the “first” or “best” match. – They face scalability issues due to the problem of combinatorial explosion. IEEE CSMR-WCRE 2014 Software Evolution Week 5
  • 6. Clone #2 Clone #1 if (orientation == VERTICAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } else if (orientation == HORIZONTAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } 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 (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } 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()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } NOT APPROVED IEEE CSMR-WCRE 2014 Software Evolution Week 6
  • 7. Clone #1 if (orientation == VERTICAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } else if (orientation == HORIZONTAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } Clone #2 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 (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } 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()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } IEEE CSMR-WCRE 2014 Software Evolution Week 7
  • 8. Clone #2 Clone #1 if (orientation == VERTICAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } else if (orientation == HORIZONTAL) { Line2D line = new Line2D.Double(); double x0 = dataArea.getMinX(); double x1 = dataArea.getMaxX(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } if (orientation == HORIZONTAL) { Line2D line = new Line2D.Double(); double y0 = dataArea.getMinY(); double y1 = dataArea.getMaxY(); g2.setPaint(im.getOutlinePaint()); g2.setStroke(im.getOutlineStroke()); if (range.contains(start)) { line.setLine(start2d, y0, start2d, y1); g2.draw(line); } if (range.contains(end)) { line.setLine(end2d, y0, end2d, y1); g2.draw(line); } } else 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 (range.contains(start)) { line.setLine(x0, start2d, x1, start2d); g2.draw(line); } if (range.contains(end)) { line.setLine(x0, end2d, x1, end2d); g2.draw(line); } } APPROVED IEEE CSMR-WCRE 2014 Software Evolution Week 8
  • 9. Minimizing differences • Minimizing the differences during the matching process is critical for refactoring. • Why? – Less differences means less parameters for the extracted method (i.e., a more reusable method). – Less differences means also lower probability for precondition violations (i.e., higher refactoring feasibility) • Matching process objectives: – Maximize the number of matched statements – Minimize the number of differences between them IEEE CSMR-WCRE 2014 Software Evolution Week 9
  • 10. Limitation #3 There are no preconditions to determine whether clones can be safely refactored. – The parameterization of differences might change the behavior of the program. – Statements in gaps need to be moved before the cloned code. Changing the order of statements might also affect the behavior of the program. IEEE CSMR-WCRE 2014 Software Evolution Week 10
  • 11. Our goal Improve the state-of-the-art in the Refactoring of Software Clones: Given two code fragments containing clones; Find potential control structures that can be refactored. Find an optimal mapping between the statements of two clones. Make sure that the refactoring of the clones will preserve program behavior. Find the most appropriate refactoring strategy to eliminate the clones. IEEE CSMR-WCRE 2014 Software Evolution Week 11
  • 12. Our approach Detected clones 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()); } Refactorable clones isomorphic differences CDT pairs unmapped statements Control Structure Matching PDG Mapping Precondition Examination IEEE CSMR-WCRE 2014 Software Evolution Week 12
  • 13. Phase 1: Control Structure Matching • Intuition: two pieces of code can be merged only if they have an identical control structure. • We extract the Control Dependence Trees (CDTs) representing the control structure of the input methods or clones. • We find all non-overlapping largest common subtrees within the CDTs. • Each subtree match will be treated as a separate refactoring opportunity. IEEE CSMR-WCRE 2014 Software Evolution Week 13
  • 14. CDT Subtree Matching CDT of Fragment #1 CDT of Fragment #2 x A a B D C E F y b G f c g d IEEE CSMR-WCRE 2014 Software Evolution Week e 14
  • 15. Phase 2: PDG Mapping • We extract the PDG subgraphs corresponding to the matched CDT subtrees. • We want to find the common subgraph that satisfies two conditions: – It has the maximum number of matched nodes – The matched nodes have the minimum number of differences. • This is an optimization problem that can be solved using an adaptation of a Maximum Common Subgraph algorithm [McGregor, 1982]. IEEE CSMR-WCRE 2014 Software Evolution Week 15
  • 16. MCS Algorithm Builds a search tree in depth-first order, where each node represents a state of the search space. Explores the entire search space. It has an exponential worst case complexity. As the number of possible matching node combinations increases, the width of the search tree grows rapidly (combinatorial explosion). IEEE CSMR-WCRE 2014 Software Evolution Week 16
  • 17. Divide-and-Conquer • We break the original matching problem into smaller sub-problems based on the control dependence structure of the clones. • Finally, we combine the sub-solutions to give a global solution to the original matching problem. IEEE CSMR-WCRE 2014 Software Evolution Week 17
  • 18. Bottom-up Divide-and-Conquer CDT subtree of Clone #1 CDT subtree of Clone #2 A a B Level 2 D C E F b G f c g IEEE CSMR-WCRE 2014 Software Evolution Week d e 18
  • 19. Bottom-up Divide-and-Conquer CDT subtree of Clone #1 CDT subtree of Clone #2 A a B Level 2 C E F b G f c g IEEE CSMR-WCRE 2014 Software Evolution Week e 19
  • 20. Phase 3: Precondition examination • Preconditions related to clone differences: – Parameterization of differences should not break existing data dependences in the PDGs. – Reordering of unmapped statements should not break existing data dependences in the PDGs. • Preconditions related to method extraction: – The unified code should return one variable at most. – Matched branching (break, continue) statements should be accompanied with the corresponding matched loops in the unified code. IEEE CSMR-WCRE 2014 Software Evolution Week 20
  • 21. Evaluation • We compared our approach with a state-ofthe-art tool in the refactoring of Type-II clones, CeDAR [Tairas & Gray, IST’12]. • 2342 clone groups, detected in 7 open-source projects by Deckard clone detection tool. • CeDAR is able to analyze only clone groups in which all clones belong to the same Java file. IEEE CSMR-WCRE 2014 Software Evolution Week 21
  • 22. Clone groups within the same Java file Project Clone groups Eclipse CeDAR JDeodorant  Ant 1.7.0 120 14 12% 28 23% 50 42% +79% Columba 1.4 88 13 15% 30 34% 41 47% +37% EMF 2.4.1 149 8 5% 14 9% 54 36% +286% JMeter 2.3.2 68 3 4% 11 16% 20 29% +82% JEdit 4.2 157 15 10% 20 13% 57 36% +185% JFreeChart 1.0.10 291 29 10% 62 21% 87 30% +40% JRuby 1.4.0 81 23 28% 23 28% 35 43% +52% Total 954 105 11% 188 20% 344 36% +83% IEEE CSMR-WCRE 2014 Software Evolution Week 22
  • 23. Clone groups within different Java files Project Clone groups JDeodorant Ant 1.7.0 211 42 20% Columba 1.4 275 66 24% EMF 2.4.1 58 12 21% JMeter 2.3.2 225 68 30% JEdit 4.2 101 21 21% JFreeChart 1.0.10 337 121 36% JRuby 1.4.0 181 43 24% Total 1388 373 27% IEEE CSMR-WCRE 2014 Software Evolution Week 23
  • 24. Conclusions • Our approach was able to refactor 83% more clone groups than CeDAR. • Our approach assessed as refactorable 27% of the clones groups, in which clones are placed in different files. • The study revealed that 36% of the clone groups can be refactored directly or in the form of sub-clones. IEEE CSMR-WCRE 2014 Software Evolution Week 24
  • 25. Visit our project at IEEE CSMR-WCRE 2014 Software Evolution Week 25