SlideShare una empresa de Scribd logo
1 de 20
Clone Refactoring with
Lambda Expressions
Nikolaos Tsantalis Davood Mazinanian Shahriar Rostami
May 24, 2017 1
Motivation
• Studied 1M+ clones detected by 4 clone detectors in
9 open-source projects [Tsantalis et al., TSE 2015]
• 94% of the clones are either Type-2 or Type-3
• Out of those, only 14% could be safely refactored
2
Because
The clones have differences that cannot be
parameterized with regular parameters.
1. Method calls or object instantiations (side-effects)
2. Unmatched statements
3
public void testGetFirstMillisecond() {
Locale saved = Locale.getDefault();
Locale.setDefault(Locale.UK);
TimeZone savedZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("London"));
assertEquals( , d.getFirstMillisecond());
Locale.setDefault(saved);
TimeZone.setDefault(savedZone);
}
public void testGetFirstMillisecond() {
Locale saved = Locale.getDefault();
Locale.setDefault(Locale.UK);
TimeZone savedZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("London"));
assertEquals( , h.getFirstMillisecond());
Locale.setDefault(saved);
TimeZone.setDefault(savedZone);
}
Day d = new Day(1, 3, 1970); Hour h = new Hour(15, 1, 4, 2006);
5094000000L 114390000000L
public void extracted( , long arg1) {
Locale saved = Locale.getDefault();
Locale.setDefault(Locale.UK);
TimeZone savedZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("London"));
assertEquals( , p.getFirstMillisecond());
Locale.setDefault(saved);
TimeZone.setDefault(savedZone);
}
public void testGetFirstMillisecond() {
extracted( , );
}
public void testGetFirstMillisecond() {
extracted( , );
}
Regular parameters
4
new Day(1, 3, 1970) new Hour(15, 1, 4, 2006)5094000000L 114390000000L
RegularTimePeriod p = arg0;
arg1
RegularTimePeriod arg0
public void testGetFirstMillisecond() {
extracted( , );
}
public void testGetFirstMillisecond() {
extracted( , );
}
Lambda parameters
5
()-> new Day(1, 3, 1970) ()-> new Hour(15, 1, 4, 2006)5094000000L 114390000000L
public void extracted( , long arg1) {
Locale saved = Locale.getDefault();
Locale.setDefault(Locale.UK);
TimeZone savedZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("London"));
assertEquals( , p.getFirstMillisecond());
Locale.setDefault(saved);
TimeZone.setDefault(savedZone);
}
RegularTimePeriod p = arg0.get();
arg1
Supplier<RegularTimePeriod> arg0
Contributions
6
• Method assessing if two clones can be refactored
with Lambda expressions.
• Eclipse plug-in automating the method
• Refactoring implementation
• Study 46K+ clones (Lambda refactorability)
• Dataset and tools publicly available
Approach in a Nutshell
7
Unificationinput output Refactorable?
Differences
between two
clones
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = regexps.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
matches =
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = contains.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
matches =
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
8
String containsStr = (String)contains.elementAt(i);
line.indexOf(containsStr)>=0;
RegularExpression regexp =
(RegularExpression)regexps.elementAt(i);
Regexp re = regexp.getRegexp(getProject());
re.matches(line);
Input [Tsantalis et al., TSE 2015]
Unification principle
9
Two code fragments can be abstracted into a
common functional interface if they:
1. Have same input parameter types
2. Have same output type
3. Throw same exception types
Unification Strategy
Starting from two differences, we perform:
1. Backward expansion, until input is the same
2. Forward expansion, until output is the same
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = regexps.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
matches = re.matches(line);
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = contains.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
matches = line.indexOf(containsStr)>=0;
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
10
String containsStr = (String)contains.elementAt(i);
RegularExpression regexp =
(RegularExpression)regexps.elementAt(i);
Regexp re = regexp.getRegexp(getProject());
Input: int i Input: int i
Output: String containsStr Output: Regexp re
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = regexps.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
public int read() throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = contains.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
11
String containsStr = (String)contains.elementAt(i);
matches = line.indexOf(containsStr)>=0;
RegularExpression regexp =
(RegularExpression)regexps.elementAt(i);
Regexp re = regexp.getRegexp(getProject());
matches = re.matches(line);
Input: int i Input: int i
Output: boolean matches Output: boolean matches
12
protected int extracted(Vector vector,
) throws IOException {
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (line != null) {
ch = line.charAt(0);
if (line.length() == 1) {
line = null;
} else {
line = line.substring(1);
}
} else {
final int size = vector.size();
for (line = readLine(); line != null; line = readLine()) {
boolean matches = true;
for (int i = 0; matches && i<size; i++) {
}
if (matches ^ isNegated()) {
break;
}
}
if (line != null) {
return read();
}
}
return ch;
}
matches = (boolean)matcher.apply(i);
Function<Integer, Boolean> matcher
Lambda parameterization
Evaluation
13
1. Correctness (compilation errors, behavior preservation)
2. Applicability (location, clone type, Template Method)
3. Characteristics (number, size, functional interface types)
RQ1. Correctness
14
• Refactored 12.6K clones assessed as Lambda
parameterizable and covered by unit tests.
• Executed the entire test suite after each refactoring
• JFreeChart test suite (less than 10 seconds)
Zero compilation errors
One test failure
RQ2. Applicability
15
• Analyzed 46.7K Type-2 & Type-3 clones from 9 projects
• non-refactorable with regular parameters
• 60% Type-2 (differences in expressions)
• 40% Type-3 (unmatched statements a.k.a. clone gaps)
Clone source code Location
58% lambda applicability
72% in test clones
51% in production clones
Clone Type
57% applicability in Type-2 clones
60% applicability in Type-3 clones
RQ2. Applicability
16
• Template Method pattern alternative to Lambdas
• clones extracted to a new or existing abstract superclass
Template Method can be used as an
alternative in only 𝟏 𝟑 of the cases
refactored with Lambda expressions
1. Clones existing in the same class, or classes without
common superclass
2. Existing common superclass cannot be made abstract,
because it is instantiated or has other subclasses
RQ3. Characteristics
17
• Analyzed 27.2K refactored clones
• Number of lambda expressions
• Relative size of lambda expression to clone fragment
• Functional interface types
Number of Lambdas Relative Lambda Size
RQ3. Characteristics
18
• Built-in functional interfaces
• Function<T,R>
• Supplier<T>
• Consumer<T>
Actual functional interface types Custom types break-down
Take-home message
19
1. Lambdas are very effective for parameterizing clones
with behavioral differences, esp. test clones
2. Lambdas are equally beneficial for parameterizing
Type-2 and Type-3 clones
3. The vast majority of clones require one or two Lambdas
4. 60% of the Lambdas can be parameterized using just
three of the Java built-in functional interface types
5. If these functional interface types supported exception
throwing, 72% of the clones could be parameterized
with built-in functional interfaces
20
https://github.com/tsantalis/JDeodorant
http://tiny.cc/ICSE17
https://github.com/tsantalis/jdeodorant-commandline

Más contenido relacionado

La actualidad más candente

TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeIosif Itkin
 
C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8Christian Nagel
 
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...corehard_by
 
OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsHari kiran G
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Anton Bikineev
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Functional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting LambdasFunctional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting LambdasGanesh Samarthyam
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Adam Mukharil Bachtiar
 
Mining Branch-Time Scenarios From Execution Logs
Mining Branch-Time Scenarios From Execution LogsMining Branch-Time Scenarios From Execution Logs
Mining Branch-Time Scenarios From Execution LogsDirk Fahland
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Adam Mukharil Bachtiar
 
OCP Java SE 8 Exam - Sample Questions - Generics and Collections
OCP Java SE 8 Exam - Sample Questions - Generics and CollectionsOCP Java SE 8 Exam - Sample Questions - Generics and Collections
OCP Java SE 8 Exam - Sample Questions - Generics and CollectionsGanesh Samarthyam
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of LambdasEsther Lozano
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupDror Helper
 

La actualidad más candente (20)

TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response Time
 
C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8C# 7.x What's new and what's coming with C# 8
C# 7.x What's new and what's coming with C# 8
 
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...
Update on C++ Core Guidelines Lifetime Analysis. Gábor Horváth. CoreHard Spri...
 
OCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertionsOCJP Samples Questions: Exceptions and assertions
OCJP Samples Questions: Exceptions and assertions
 
Writing good std::future&lt;c++>
Writing good std::future&lt;c++>Writing good std::future&lt;c++>
Writing good std::future&lt;c++>
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Functional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting LambdasFunctional Programming in Java 8 - Exploiting Lambdas
Functional Programming in Java 8 - Exploiting Lambdas
 
Java Generics - by Example
Java Generics - by ExampleJava Generics - by Example
Java Generics - by Example
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Mining Branch-Time Scenarios From Execution Logs
Mining Branch-Time Scenarios From Execution LogsMining Branch-Time Scenarios From Execution Logs
Mining Branch-Time Scenarios From Execution Logs
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
 
Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
OCP Java SE 8 Exam - Sample Questions - Generics and Collections
OCP Java SE 8 Exam - Sample Questions - Generics and CollectionsOCP Java SE 8 Exam - Sample Questions - Generics and Collections
OCP Java SE 8 Exam - Sample Questions - Generics and Collections
 
The... Wonderful? World of Lambdas
The... Wonderful? World of LambdasThe... Wonderful? World of Lambdas
The... Wonderful? World of Lambdas
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
Mutation @ Spotify
Mutation @ Spotify Mutation @ Spotify
Mutation @ Spotify
 

Similar a Clone Refactoring with Lambda Expressions

The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type PatternsSimon Ritter
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimizedWoody Pewitt
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#Rohit Rao
 
ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.pptMahyuddin8
 
Scala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and ImplementationsScala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and ImplementationsMICHRAFY MUSTAFA
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8franciscoortin
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?Patrick Lam
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetupsource{d}
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Yulia Tsisyk
 

Similar a Clone Refactoring with Lambda Expressions (20)

The Art of Java Type Patterns
The Art of Java Type PatternsThe Art of Java Type Patterns
The Art of Java Type Patterns
 
Functional concepts in C#
Functional concepts in C#Functional concepts in C#
Functional concepts in C#
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
C# - What's next
C# - What's nextC# - What's next
C# - What's next
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
For Beginners - C#
For Beginners - C#For Beginners - C#
For Beginners - C#
 
Computer programming 2 Lesson 10
Computer programming 2  Lesson 10Computer programming 2  Lesson 10
Computer programming 2 Lesson 10
 
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
 
ch04-conditional-execution.ppt
ch04-conditional-execution.pptch04-conditional-execution.ppt
ch04-conditional-execution.ppt
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Scala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and ImplementationsScala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and Implementations
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
core java
 core java core java
core java
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?
 
Scala @ TomTom
Scala @ TomTomScala @ TomTom
Scala @ TomTom
 
Machine Learning on Code - SF meetup
Machine Learning on Code - SF meetupMachine Learning on Code - SF meetup
Machine Learning on Code - SF meetup
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"
 

Más de 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 evolutionNikolaos 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 TalkNikolaos Tsantalis
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkNikolaos 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 HistoryNikolaos 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 ContributorsNikolaos Tsantalis
 
Migrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsMigrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsNikolaos 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 preprocessorsNikolaos 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 PreprocessorsNikolaos 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 DirectionsNikolaos 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 FutureNikolaos 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 SheetsNikolaos 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 VolatilityNikolaos 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 ApplicationsNikolaos 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 ActivityNikolaos Tsantalis
 
Unification and Refactoring of Clones
Unification and Refactoring of ClonesUnification and Refactoring of Clones
Unification and Refactoring of ClonesNikolaos Tsantalis
 

Más de 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
 
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
 
Unification and Refactoring of Clones
Unification and Refactoring of ClonesUnification and Refactoring of Clones
Unification and Refactoring of Clones
 

Último

GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.Nitya salvi
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyDrAnita Sharma
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 

Último (20)

GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 

Clone Refactoring with Lambda Expressions

  • 1. Clone Refactoring with Lambda Expressions Nikolaos Tsantalis Davood Mazinanian Shahriar Rostami May 24, 2017 1
  • 2. Motivation • Studied 1M+ clones detected by 4 clone detectors in 9 open-source projects [Tsantalis et al., TSE 2015] • 94% of the clones are either Type-2 or Type-3 • Out of those, only 14% could be safely refactored 2
  • 3. Because The clones have differences that cannot be parameterized with regular parameters. 1. Method calls or object instantiations (side-effects) 2. Unmatched statements 3 public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("London")); assertEquals( , d.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("London")); assertEquals( , h.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } Day d = new Day(1, 3, 1970); Hour h = new Hour(15, 1, 4, 2006); 5094000000L 114390000000L
  • 4. public void extracted( , long arg1) { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("London")); assertEquals( , p.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } public void testGetFirstMillisecond() { extracted( , ); } public void testGetFirstMillisecond() { extracted( , ); } Regular parameters 4 new Day(1, 3, 1970) new Hour(15, 1, 4, 2006)5094000000L 114390000000L RegularTimePeriod p = arg0; arg1 RegularTimePeriod arg0
  • 5. public void testGetFirstMillisecond() { extracted( , ); } public void testGetFirstMillisecond() { extracted( , ); } Lambda parameters 5 ()-> new Day(1, 3, 1970) ()-> new Hour(15, 1, 4, 2006)5094000000L 114390000000L public void extracted( , long arg1) { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("London")); assertEquals( , p.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); } RegularTimePeriod p = arg0.get(); arg1 Supplier<RegularTimePeriod> arg0
  • 6. Contributions 6 • Method assessing if two clones can be refactored with Lambda expressions. • Eclipse plug-in automating the method • Refactoring implementation • Study 46K+ clones (Lambda refactorability) • Dataset and tools publicly available
  • 7. Approach in a Nutshell 7 Unificationinput output Refactorable? Differences between two clones
  • 8. public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = regexps.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { matches = } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = contains.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { matches = } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } 8 String containsStr = (String)contains.elementAt(i); line.indexOf(containsStr)>=0; RegularExpression regexp = (RegularExpression)regexps.elementAt(i); Regexp re = regexp.getRegexp(getProject()); re.matches(line); Input [Tsantalis et al., TSE 2015]
  • 9. Unification principle 9 Two code fragments can be abstracted into a common functional interface if they: 1. Have same input parameter types 2. Have same output type 3. Throw same exception types Unification Strategy Starting from two differences, we perform: 1. Backward expansion, until input is the same 2. Forward expansion, until output is the same
  • 10. public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = regexps.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { matches = re.matches(line); } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = contains.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { matches = line.indexOf(containsStr)>=0; } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } 10 String containsStr = (String)contains.elementAt(i); RegularExpression regexp = (RegularExpression)regexps.elementAt(i); Regexp re = regexp.getRegexp(getProject()); Input: int i Input: int i Output: String containsStr Output: Regexp re
  • 11. public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = regexps.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } public int read() throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = contains.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } 11 String containsStr = (String)contains.elementAt(i); matches = line.indexOf(containsStr)>=0; RegularExpression regexp = (RegularExpression)regexps.elementAt(i); Regexp re = regexp.getRegexp(getProject()); matches = re.matches(line); Input: int i Input: int i Output: boolean matches Output: boolean matches
  • 12. 12 protected int extracted(Vector vector, ) throws IOException { if (!getInitialized()) { initialize(); setInitialized(true); } int ch = -1; if (line != null) { ch = line.charAt(0); if (line.length() == 1) { line = null; } else { line = line.substring(1); } } else { final int size = vector.size(); for (line = readLine(); line != null; line = readLine()) { boolean matches = true; for (int i = 0; matches && i<size; i++) { } if (matches ^ isNegated()) { break; } } if (line != null) { return read(); } } return ch; } matches = (boolean)matcher.apply(i); Function<Integer, Boolean> matcher Lambda parameterization
  • 13. Evaluation 13 1. Correctness (compilation errors, behavior preservation) 2. Applicability (location, clone type, Template Method) 3. Characteristics (number, size, functional interface types)
  • 14. RQ1. Correctness 14 • Refactored 12.6K clones assessed as Lambda parameterizable and covered by unit tests. • Executed the entire test suite after each refactoring • JFreeChart test suite (less than 10 seconds) Zero compilation errors One test failure
  • 15. RQ2. Applicability 15 • Analyzed 46.7K Type-2 & Type-3 clones from 9 projects • non-refactorable with regular parameters • 60% Type-2 (differences in expressions) • 40% Type-3 (unmatched statements a.k.a. clone gaps) Clone source code Location 58% lambda applicability 72% in test clones 51% in production clones Clone Type 57% applicability in Type-2 clones 60% applicability in Type-3 clones
  • 16. RQ2. Applicability 16 • Template Method pattern alternative to Lambdas • clones extracted to a new or existing abstract superclass Template Method can be used as an alternative in only 𝟏 𝟑 of the cases refactored with Lambda expressions 1. Clones existing in the same class, or classes without common superclass 2. Existing common superclass cannot be made abstract, because it is instantiated or has other subclasses
  • 17. RQ3. Characteristics 17 • Analyzed 27.2K refactored clones • Number of lambda expressions • Relative size of lambda expression to clone fragment • Functional interface types Number of Lambdas Relative Lambda Size
  • 18. RQ3. Characteristics 18 • Built-in functional interfaces • Function<T,R> • Supplier<T> • Consumer<T> Actual functional interface types Custom types break-down
  • 19. Take-home message 19 1. Lambdas are very effective for parameterizing clones with behavioral differences, esp. test clones 2. Lambdas are equally beneficial for parameterizing Type-2 and Type-3 clones 3. The vast majority of clones require one or two Lambdas 4. 60% of the Lambdas can be parameterized using just three of the Java built-in functional interface types 5. If these functional interface types supported exception throwing, 72% of the clones could be parameterized with built-in functional interfaces