SlideShare a Scribd company logo
A journey to automatic Java refactoring
Software Quality Days 2019
Martin Huter & Ardit Ymeri
A journey to automatic Java
refactoring (and jSparrow)
A journey to automatic Java refactoring
Who are we?
Slide 2
A journey to automatic Java refactoring
Agenda
▪ Refactoring
▪ Software aiding the refactoring process
▪ Creating an automatic refactoring tool
Slide 3
A journey to automatic Java refactoring
Management: Do we really need that?
Refactoring
Slide 4
A journey to automatic Java refactoring
What is Refactoring
Slide 5
▪ Changing the code and keeping functionality
▪ Reasons include
▪ Improve readability
▪ Reduce complexity
▪ Improve maintainability
▪ Improve internal architecture
▪ Improve performance
▪ Improve security
▪ Parallelization
A journey to automatic Java refactoring
Typical Problems
▪ Design and code structure
▪ Lack of Cohesion
▪ Tight Coupling
▪ Repeated Code
▪ Spaghetti Code
▪ Lack of Performance
▪ Lack of Tests
▪ Security Issues
Slide 6
A journey to automatic Java refactoring
Human Approach
▪ Define a goal
▪ Understand the code base
▪ Set up a safety net - Tests!
▪ Refactor
▪ Go with baby steps
▪ Test
▪ Does everything still work?
▪ Repeat
Slide 7
Refactor
Test
A journey to automatic Java refactoring
Preserving Functionality
▪ Testing helps - but never guarantees.
▪ Program Equivalence
▪ Do programs P and Q terminate on the same state when starting on the same
one?
▪ Reducible to the Halting Problem.
▪ Undecidable!!!
▪ All nontrivial semantic properties are undecidable 👉 Rice’s Theorem
▪ The good news: Undecidable only in general!
▪ Show correctness for specific cases
▪ Trivial properties are decidable.
Slide 8
A journey to automatic Java refactoring
Using Functional Interfaces
Slide 9
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
passwordField.requestFocusInWindow();
passwordField.requestFocus();
}
});
SwingUtilities.invokeLater(() -> {
passwordField.requestFocusInWindow();
passwordField.requestFocus();
});
A journey to automatic Java refactoring
Using Standard Outputs
Slide 10
System.err.println(e.getMessage());
logger.error(e.getMessage());
e.printStackTrace();
logger.error(e.getMessage(), e);
A journey to automatic Java refactoring
Cognitive Complexity
Slide 11
public void remapIds() {
Attribute idAttribute = getAttributes();
if (idAttribute != null) {
// very long code
…
}
}
public void remapIds() {
Attribute idAttribute = getAttributes();
if (idAttribute == null) {
return;
}
// very long code
…
}
A journey to automatic Java refactoring
Other Code Smells
Slide 12
▪ Methods should not be empty
▪ Deprecated code should be removed
▪ Sections of code should not be commented out
@Deprecated
public static void doSomething(Object changeMe) {
// throw new UnsupportedOperationException();
}
A journey to automatic Java refactoring
There is Software that might help
Help me?
Slide 13
A journey to automatic Java refactoring
Assessing Technical Debt
Slide 14
▪ Existing Solutions
▪ Integration in development process
▪ Reporting technical debt
▪ Evaluating efforts
A journey to automatic Java refactoring
Addressing Technical Debt
Common scenarios for 100k lines
▪ 10s Thousands issues
▪ Hundreds working days
Addressing by:
▪ Avoid creating more debt
▪ Continuously removing debt
▪ Automatically resolving issues
Slide 15
A journey to automatic Java refactoring
Resolving Automatically
▪ Spotting issues
▪ Generating refactored code
▪ Avoiding Conflicts
▪ Preserving Functionality
▪ Test automation
▪ Preserving Comments
Slide 16
A journey to automatic Java refactoring
From Spotting to fixing
Can I automate that?
Slide 17
A journey to automatic Java refactoring
Change source with AST
Slide 18
1
Parsing
source
to
AST
Firstyou
need
a
toolthatw
illparse
your
source
code
like
a
com
piler
2
M
anipulating
AST
Use
the
resulting
AST
to
adoptthe
code
and
apply
fixes
3
Assure
syntax
stillvalid
Verify
changes
resultin
a
valid
source
code
4
W
riting
Changes
Apply
the
changes
to
the
source
file
and
replace
it
A journey to automatic Java refactoring
What framework to use?
Slide 19
Java Grammar Java Compiler Advantages of the Framework
● Open source
● Integrated within Eclipse IDE
1 Eclipse JDT
● Open source
● Integrated within Intellij IDE
2 Javaparser.org
● Mostly independent
● Building a lot from scratch
3 Antlr 4
A journey to automatic Java refactoring
jSparrow
Slide 20
Eclipse JDT
Eclipse Plugin
GitHub App
Maven Plugin
A journey to automatic Java refactoring
Automatic Refactoring
● Pros
+ Save time
+ Reduce debt
+ Set standards
+ Integration in development process
+ Improve coding habits
● Cons
- Technical restrictions
Slide 21
A journey to automatic Java refactoring
jSparrow Features
▪ 53 Rules and growing
▪ Custom rule profiles
▪ Portable between platforms
▪ Built-in review functionality
Slide 22
A journey to automatic Java refactoring
The end
▪ Thanks for your time, we now got some time left to discuss
questions.
▪ You can also visit us at our booth at number 13
Slide 23

More Related Content

What's hot

Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
Victor Rentea
 
TDD Updated
TDD UpdatedTDD Updated
TDD Updated
Harshit Jain
 
Project AutoMock and Jasmine: Testing Auto-magically!!
Project AutoMock and Jasmine: Testing Auto-magically!!Project AutoMock and Jasmine: Testing Auto-magically!!
Project AutoMock and Jasmine: Testing Auto-magically!!
harshit040591
 
Clean Lambdas at JBCNConf by Victor Rentea
Clean Lambdas at JBCNConf by Victor RenteaClean Lambdas at JBCNConf by Victor Rentea
Clean Lambdas at JBCNConf by Victor Rentea
Victor Rentea
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 Proxy
Alexandr Skachkov
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
Victor Rentea
 
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DB
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DBWeb aplikāciju izstrāde ar Ruby on Rails un Oracle DB
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DBRaimonds Simanovskis
 
The need for speed. What is GraalVM?
The need for speed. What is GraalVM?The need for speed. What is GraalVM?
The need for speed. What is GraalVM?
Maciej Przepióra
 
Xlab #2: wzorce projektowe
Xlab #2: wzorce projektoweXlab #2: wzorce projektowe
Xlab #2: wzorce projektowe
XSolve
 
A Tale About the Evil Partial Mock and Separation by Layers of Abstractions
A Tale About the Evil Partial Mock and Separation by Layers of AbstractionsA Tale About the Evil Partial Mock and Separation by Layers of Abstractions
A Tale About the Evil Partial Mock and Separation by Layers of Abstractions
Victor Rentea
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
nishajj
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021
Victor Rentea
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)
Alin Pandichi
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
Elias Nogueira
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
Bertrand Delacretaz
 
140 releases per month
140 releases per month140 releases per month
140 releases per month
Manuel Vacelet
 
QA 4 python
QA 4 pythonQA 4 python
QA 4 python
BeDjango
 
Automatic constraints as a team maturity accelerator for startups
Automatic constraints as a team maturity accelerator for startupsAutomatic constraints as a team maturity accelerator for startups
Automatic constraints as a team maturity accelerator for startups
François-Guillaume Ribreau
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
Testing PHP with Codeception
Testing PHP with CodeceptionTesting PHP with Codeception
Testing PHP with Codeception
John Paul Ada
 

What's hot (20)

Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
TDD Updated
TDD UpdatedTDD Updated
TDD Updated
 
Project AutoMock and Jasmine: Testing Auto-magically!!
Project AutoMock and Jasmine: Testing Auto-magically!!Project AutoMock and Jasmine: Testing Auto-magically!!
Project AutoMock and Jasmine: Testing Auto-magically!!
 
Clean Lambdas at JBCNConf by Victor Rentea
Clean Lambdas at JBCNConf by Victor RenteaClean Lambdas at JBCNConf by Victor Rentea
Clean Lambdas at JBCNConf by Victor Rentea
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 Proxy
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DB
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DBWeb aplikāciju izstrāde ar Ruby on Rails un Oracle DB
Web aplikāciju izstrāde ar Ruby on Rails un Oracle DB
 
The need for speed. What is GraalVM?
The need for speed. What is GraalVM?The need for speed. What is GraalVM?
The need for speed. What is GraalVM?
 
Xlab #2: wzorce projektowe
Xlab #2: wzorce projektoweXlab #2: wzorce projektowe
Xlab #2: wzorce projektowe
 
A Tale About the Evil Partial Mock and Separation by Layers of Abstractions
A Tale About the Evil Partial Mock and Separation by Layers of AbstractionsA Tale About the Evil Partial Mock and Separation by Layers of Abstractions
A Tale About the Evil Partial Mock and Separation by Layers of Abstractions
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021
 
Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)Unit Testing your React / Redux app (@BucharestJS)
Unit Testing your React / Redux app (@BucharestJS)
 
Java Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and MobileJava Test Automation for REST, Web and Mobile
Java Test Automation for REST, Web and Mobile
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
 
140 releases per month
140 releases per month140 releases per month
140 releases per month
 
QA 4 python
QA 4 pythonQA 4 python
QA 4 python
 
Automatic constraints as a team maturity accelerator for startups
Automatic constraints as a team maturity accelerator for startupsAutomatic constraints as a team maturity accelerator for startups
Automatic constraints as a team maturity accelerator for startups
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
 
Testing PHP with Codeception
Testing PHP with CodeceptionTesting PHP with Codeception
Testing PHP with Codeception
 

Similar to Automatic Java Refactoring

Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesHenrik Olsson
 
Audit your reactive applications
Audit your reactive applicationsAudit your reactive applications
Audit your reactive applications
OCTO Technology
 
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Dan Allen
 
Concurrency
ConcurrencyConcurrency
Concurrency
Isaac Liao
 
Java introduction
Java introductionJava introduction
Java introduction
The icfai university jaipur
 
Stripe con 2021 UI stack
Stripe con 2021 UI stackStripe con 2021 UI stack
Stripe con 2021 UI stack
MaximeRainville1
 
Gain more freedom when migrating from Camunda 7 to 8.pdf
Gain more freedom when migrating from Camunda 7 to 8.pdfGain more freedom when migrating from Camunda 7 to 8.pdf
Gain more freedom when migrating from Camunda 7 to 8.pdf
Phactum Softwareentwicklung GmbH
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Introduction to Binary Exploitation
Introduction to Binary Exploitation	Introduction to Binary Exploitation
Introduction to Binary Exploitation
Cysinfo Cyber Security Community
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
Marharyta Nedzelska
 
Continuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreContinuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyre
Spark Summit
 
Cloudstack Continuous Delivery
Cloudstack Continuous DeliveryCloudstack Continuous Delivery
Cloudstack Continuous Deliverybuildacloud
 
Determinism in finance
Determinism in financeDeterminism in finance
Determinism in finance
Peter Lawrey
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
Troy Miles
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2Uday Sharma
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and Profit
Joshua Ballanco
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains Webinar
Trisha Gee
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdf
Victor Rentea
 
(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?
Steve Poole
 

Similar to Automatic Java Refactoring (20)

Ten Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project ExperiencesTen Man-Years of JavaFX: Real World Project Experiences
Ten Man-Years of JavaFX: Real World Project Experiences
 
Audit your reactive applications
Audit your reactive applicationsAudit your reactive applications
Audit your reactive applications
 
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Java introduction
Java introductionJava introduction
Java introduction
 
Stripe con 2021 UI stack
Stripe con 2021 UI stackStripe con 2021 UI stack
Stripe con 2021 UI stack
 
Gain more freedom when migrating from Camunda 7 to 8.pdf
Gain more freedom when migrating from Camunda 7 to 8.pdfGain more freedom when migrating from Camunda 7 to 8.pdf
Gain more freedom when migrating from Camunda 7 to 8.pdf
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to Binary Exploitation
Introduction to Binary Exploitation	Introduction to Binary Exploitation
Introduction to Binary Exploitation
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Continuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreContinuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyre
 
Cloudstack Continuous Delivery
Cloudstack Continuous DeliveryCloudstack Continuous Delivery
Cloudstack Continuous Delivery
 
Determinism in finance
Determinism in financeDeterminism in finance
Determinism in finance
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Fundamentals of java --- version 2
Fundamentals of java --- version 2Fundamentals of java --- version 2
Fundamentals of java --- version 2
 
MacRuby for Fun and Profit
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and Profit
 
Real World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains WebinarReal World Java 9 - JetBrains Webinar
Real World Java 9 - JetBrains Webinar
 
Eclipse UI automation
Eclipse UI automationEclipse UI automation
Eclipse UI automation
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdf
 
(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?(java2days) Is the Future of Java Cloudy?
(java2days) Is the Future of Java Cloudy?
 

Recently uploaded

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 

Automatic Java Refactoring

  • 1. A journey to automatic Java refactoring Software Quality Days 2019 Martin Huter & Ardit Ymeri A journey to automatic Java refactoring (and jSparrow)
  • 2. A journey to automatic Java refactoring Who are we? Slide 2
  • 3. A journey to automatic Java refactoring Agenda ▪ Refactoring ▪ Software aiding the refactoring process ▪ Creating an automatic refactoring tool Slide 3
  • 4. A journey to automatic Java refactoring Management: Do we really need that? Refactoring Slide 4
  • 5. A journey to automatic Java refactoring What is Refactoring Slide 5 ▪ Changing the code and keeping functionality ▪ Reasons include ▪ Improve readability ▪ Reduce complexity ▪ Improve maintainability ▪ Improve internal architecture ▪ Improve performance ▪ Improve security ▪ Parallelization
  • 6. A journey to automatic Java refactoring Typical Problems ▪ Design and code structure ▪ Lack of Cohesion ▪ Tight Coupling ▪ Repeated Code ▪ Spaghetti Code ▪ Lack of Performance ▪ Lack of Tests ▪ Security Issues Slide 6
  • 7. A journey to automatic Java refactoring Human Approach ▪ Define a goal ▪ Understand the code base ▪ Set up a safety net - Tests! ▪ Refactor ▪ Go with baby steps ▪ Test ▪ Does everything still work? ▪ Repeat Slide 7 Refactor Test
  • 8. A journey to automatic Java refactoring Preserving Functionality ▪ Testing helps - but never guarantees. ▪ Program Equivalence ▪ Do programs P and Q terminate on the same state when starting on the same one? ▪ Reducible to the Halting Problem. ▪ Undecidable!!! ▪ All nontrivial semantic properties are undecidable 👉 Rice’s Theorem ▪ The good news: Undecidable only in general! ▪ Show correctness for specific cases ▪ Trivial properties are decidable. Slide 8
  • 9. A journey to automatic Java refactoring Using Functional Interfaces Slide 9 SwingUtilities.invokeLater(new Runnable() { @Override public void run() { passwordField.requestFocusInWindow(); passwordField.requestFocus(); } }); SwingUtilities.invokeLater(() -> { passwordField.requestFocusInWindow(); passwordField.requestFocus(); });
  • 10. A journey to automatic Java refactoring Using Standard Outputs Slide 10 System.err.println(e.getMessage()); logger.error(e.getMessage()); e.printStackTrace(); logger.error(e.getMessage(), e);
  • 11. A journey to automatic Java refactoring Cognitive Complexity Slide 11 public void remapIds() { Attribute idAttribute = getAttributes(); if (idAttribute != null) { // very long code … } } public void remapIds() { Attribute idAttribute = getAttributes(); if (idAttribute == null) { return; } // very long code … }
  • 12. A journey to automatic Java refactoring Other Code Smells Slide 12 ▪ Methods should not be empty ▪ Deprecated code should be removed ▪ Sections of code should not be commented out @Deprecated public static void doSomething(Object changeMe) { // throw new UnsupportedOperationException(); }
  • 13. A journey to automatic Java refactoring There is Software that might help Help me? Slide 13
  • 14. A journey to automatic Java refactoring Assessing Technical Debt Slide 14 ▪ Existing Solutions ▪ Integration in development process ▪ Reporting technical debt ▪ Evaluating efforts
  • 15. A journey to automatic Java refactoring Addressing Technical Debt Common scenarios for 100k lines ▪ 10s Thousands issues ▪ Hundreds working days Addressing by: ▪ Avoid creating more debt ▪ Continuously removing debt ▪ Automatically resolving issues Slide 15
  • 16. A journey to automatic Java refactoring Resolving Automatically ▪ Spotting issues ▪ Generating refactored code ▪ Avoiding Conflicts ▪ Preserving Functionality ▪ Test automation ▪ Preserving Comments Slide 16
  • 17. A journey to automatic Java refactoring From Spotting to fixing Can I automate that? Slide 17
  • 18. A journey to automatic Java refactoring Change source with AST Slide 18 1 Parsing source to AST Firstyou need a toolthatw illparse your source code like a com piler 2 M anipulating AST Use the resulting AST to adoptthe code and apply fixes 3 Assure syntax stillvalid Verify changes resultin a valid source code 4 W riting Changes Apply the changes to the source file and replace it
  • 19. A journey to automatic Java refactoring What framework to use? Slide 19 Java Grammar Java Compiler Advantages of the Framework ● Open source ● Integrated within Eclipse IDE 1 Eclipse JDT ● Open source ● Integrated within Intellij IDE 2 Javaparser.org ● Mostly independent ● Building a lot from scratch 3 Antlr 4
  • 20. A journey to automatic Java refactoring jSparrow Slide 20 Eclipse JDT Eclipse Plugin GitHub App Maven Plugin
  • 21. A journey to automatic Java refactoring Automatic Refactoring ● Pros + Save time + Reduce debt + Set standards + Integration in development process + Improve coding habits ● Cons - Technical restrictions Slide 21
  • 22. A journey to automatic Java refactoring jSparrow Features ▪ 53 Rules and growing ▪ Custom rule profiles ▪ Portable between platforms ▪ Built-in review functionality Slide 22
  • 23. A journey to automatic Java refactoring The end ▪ Thanks for your time, we now got some time left to discuss questions. ▪ You can also visit us at our booth at number 13 Slide 23