SlideShare a Scribd company logo
Making Software Refactorings Safer
Anna Maria Eilertsen
@Sowhow
Supervised by: Anya Bagge1
Volker Stolz 2
1Inst. for Informatikk, Universitetet i Bergen
2Inst. for Data- og Realfag, Høgskolen i Bergen
Norway
July 12, 2016
The results of this thesis has been accepted to the ISOLA1
conference as a paper.
1
http://www.isola-conference.org/isola2016/
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 1 / 14
Software Refactorings
“Behaviour preserving program
transformation”
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 2 / 14
Software Refactoring Tools
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 3 / 14
Unsafe Refactorings
“The primary risk is regression, mostly from
misunderstanding subtle corner cases in the
original code and not accounting for them
in the refactored code.”
– interviewee, Microsoft developer,
Kim et al., 2012
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 4 / 14
Unsafe Refactoring Example
Extract Local Variable
In Java/Eclipse:
Before
1 public void f() {
2 x.n();
3 setX();
4 x.n();
5 }
After
1 public void f() {
2 X temp = x;
3 temp.n();
4 setX();
5 temp.n();
6 }
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 5 / 14
An analysing problem
x = new X();
setX(); // x = new X();
1 public void f() {
2 X temp = x;
3 temp.n();
4 setX();
5 temp.n();
6 }
Solution:
assert temp == x;
∗
Dog art from Hyperbole and a Half
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 6 / 14
Extract Local Variable
Simplified example:
1 public class C {
2 public X x = new X();
3 {//initializer
4 x.myC = this;
5 }
6
7 public void f(){
8 x.n();
9 x.m();
0 x.n();
1 }
2 }
1 public class X{
2 public C myC;
3
4 public void m(){
5 myC.x = new X();
6 }
7
8 public void n(){
9 System.out.println(
10 this.hashCode());
11 }
12 }
Output:
1735600054
21685669 skip example
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 7 / 14
Extract Local Variable
Refactored:
1 public class C {
2 public X x = new X();
3 {//initializer
4 x.myC = this;
5 }
6
7 public void f(){
8 X temp = x;
9 temp.n();
0 temp.m();
1 temp.n();
2 }
3 }
1 public class X{
2 public C myC;
3
4 public void m(){
5 myC.x = new X();
6 }
7
8 public void n(){
9 System.out.println(
10 this.hashCode());
11 }
12 }
Output:
1735600054
1735600054
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 8 / 14
Extract Local Variable
With dynamic checks:
1 public class C {
2 public X x = new X();
3 {//initializer
4 x.myC = this;
5 }
6 public void f(){
7 X temp = x;
8 assert temp == x;
9 temp.n();
0 assert temp == x;
1 temp.m();
2 assert temp == x;
3 temp.n();
1 public class X{
2 public C myC;
3
4 public void m(){
5 myC.x = new X();
6 }
7
8 public void n(){
9 System.out.println(
10 this.hashCode());
11 }
12 }
Output:
1735600054
Exception in thread ”main” java.lang.AssertionError
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 9 / 14
Extract And Move Method
A similar problem:
1 public class C {
2 public X x = new X();
3 {//initializer
4 x.myC = this;
5 }
6 public void f(){
7 x.bar(this);
8 }
9 }
1 public class X{
2 ...
3 void bar(C c){
4 this.n();
5 assert this == c.x;
6 this.m();
7 assert this == c.x;
8 this.n();
9 }
10 }
Similar how?
Evaluate x once.
Refer to that value by this
Substitute every occurrence of x with this
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 10 / 14
Experiment: Case study
Case: Eclipse JDT UI source code
Experiment:
Execute our modified refactorings on Eclipse JDT UI project
Run Eclipse test suite
Look for triggered asserts
Profit!!
Need custom automated refactoring tool.
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 11 / 14
Experiment: Results
Extract Local Extract and
Variable Move Method
Executed refactorings 4538 755
Total number of asserts 7665 610
Resulting compile errors 0 14
Successful Tests 2392 2151
Unsuccessful Tests 4 245
Asserts triggered 2 / 136∗ 0
∗ 136 instances of the same 2 assert statements
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 12 / 14
Discussion
Take-away and questions:
Extract Local Extract and
Variable Move Method
Executed refactorings 4538 755
Total number of asserts 7665 610
Resulting compile errors 0 14
Successful Tests 2392 2151
Unsuccessful Tests 4 245
Asserts triggered 2 / 136 0
Dynamic preconditions can be useful!
Assert statements are incomplete.
Show or hide the asserts from the programmer?
Is reference equivalence too strict?
Thank you!
∗
Art with face is from Hyperbole and a Half
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 13 / 14
Experiment: Development
Eclipse refactoring plug-in
Modify Eclipse’s refactorings to introduce asserts
Extract Local Variable
Extract And Move Method
Automate refactoring process
Execute on Java project
One refactoring per method
Custom heuristic for finding refactoring targets
Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 14 / 14

More Related Content

Similar to Making Software Refactorings Safer

Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2
gregoryg
 
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & AlluxioUltra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
Alluxio, Inc.
 
MNE group analysis presentation @ Biomag 2016 conf.
MNE group analysis presentation @ Biomag 2016 conf.MNE group analysis presentation @ Biomag 2016 conf.
MNE group analysis presentation @ Biomag 2016 conf.
agramfort
 
A science-gateway for workflow executions: online and non-clairvoyant self-h...
A science-gateway for workflow executions: online and non-clairvoyant self-h...A science-gateway for workflow executions: online and non-clairvoyant self-h...
A science-gateway for workflow executions: online and non-clairvoyant self-h...
Rafael Ferreira da Silva
 
Scaling Deep Learning Algorithms on Extreme Scale Architectures
Scaling Deep Learning Algorithms on Extreme Scale ArchitecturesScaling Deep Learning Algorithms on Extreme Scale Architectures
Scaling Deep Learning Algorithms on Extreme Scale Architectures
inside-BigData.com
 
Introduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningIntroduction to Model-Based Machine Learning
Introduction to Model-Based Machine Learning
Daniel Emaasit
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
Paolo Missier
 
Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582Editor IJARCET
 
SC1 - Hangout 2: The Open PHACTS pilot
SC1 - Hangout 2: The Open PHACTS pilotSC1 - Hangout 2: The Open PHACTS pilot
SC1 - Hangout 2: The Open PHACTS pilot
BigData_Europe
 
Correctness attraction __kth_2017
Correctness attraction __kth_2017Correctness attraction __kth_2017
Correctness attraction __kth_2017
Benjamin Danglot
 
OKE2018 Challenge @ ESWC2018
OKE2018 Challenge @ ESWC2018OKE2018 Challenge @ ESWC2018
OKE2018 Challenge @ ESWC2018
Holistic Benchmarking of Big Linked Data
 
Computer Tools for Academic Research
Computer Tools for Academic ResearchComputer Tools for Academic Research
Computer Tools for Academic ResearchMiklos Koren
 
Analytics of analytics pipelines: from optimising re-execution to general Dat...
Analytics of analytics pipelines:from optimising re-execution to general Dat...Analytics of analytics pipelines:from optimising re-execution to general Dat...
Analytics of analytics pipelines: from optimising re-execution to general Dat...
Paolo Missier
 
An Empirical Study of Identical Function Clones in CRAN
An Empirical Study of Identical Function Clones in CRANAn Empirical Study of Identical Function Clones in CRAN
An Empirical Study of Identical Function Clones in CRAN
Tom Mens
 
Curriculum Vitae
Curriculum VitaeCurriculum Vitae
Curriculum Vitae
Andy Nisbet
 
Automating Environmental Computing Applications with Scientific Workflows
Automating Environmental Computing Applications with Scientific WorkflowsAutomating Environmental Computing Applications with Scientific Workflows
Automating Environmental Computing Applications with Scientific Workflows
Rafael Ferreira da Silva
 
H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215
Sri Ambati
 
AI Development with H2O.ai
AI Development with H2O.aiAI Development with H2O.ai
AI Development with H2O.ai
Yalçın Yenigün
 
Machine learning key to your formulation challenges
Machine learning key to your formulation challengesMachine learning key to your formulation challenges
Machine learning key to your formulation challenges
Marc Borowczak
 

Similar to Making Software Refactorings Safer (20)

Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2
 
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & AlluxioUltra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
Ultra Fast Deep Learning in Hybrid Cloud Using Intel Analytics Zoo & Alluxio
 
MNE group analysis presentation @ Biomag 2016 conf.
MNE group analysis presentation @ Biomag 2016 conf.MNE group analysis presentation @ Biomag 2016 conf.
MNE group analysis presentation @ Biomag 2016 conf.
 
A science-gateway for workflow executions: online and non-clairvoyant self-h...
A science-gateway for workflow executions: online and non-clairvoyant self-h...A science-gateway for workflow executions: online and non-clairvoyant self-h...
A science-gateway for workflow executions: online and non-clairvoyant self-h...
 
Scaling Deep Learning Algorithms on Extreme Scale Architectures
Scaling Deep Learning Algorithms on Extreme Scale ArchitecturesScaling Deep Learning Algorithms on Extreme Scale Architectures
Scaling Deep Learning Algorithms on Extreme Scale Architectures
 
Introduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningIntroduction to Model-Based Machine Learning
Introduction to Model-Based Machine Learning
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582Ijarcet vol-2-issue-4-1579-1582
Ijarcet vol-2-issue-4-1579-1582
 
SC1 - Hangout 2: The Open PHACTS pilot
SC1 - Hangout 2: The Open PHACTS pilotSC1 - Hangout 2: The Open PHACTS pilot
SC1 - Hangout 2: The Open PHACTS pilot
 
Correctness attraction __kth_2017
Correctness attraction __kth_2017Correctness attraction __kth_2017
Correctness attraction __kth_2017
 
OKE2018 Challenge @ ESWC2018
OKE2018 Challenge @ ESWC2018OKE2018 Challenge @ ESWC2018
OKE2018 Challenge @ ESWC2018
 
Computer Tools for Academic Research
Computer Tools for Academic ResearchComputer Tools for Academic Research
Computer Tools for Academic Research
 
Analytics of analytics pipelines: from optimising re-execution to general Dat...
Analytics of analytics pipelines:from optimising re-execution to general Dat...Analytics of analytics pipelines:from optimising re-execution to general Dat...
Analytics of analytics pipelines: from optimising re-execution to general Dat...
 
An Empirical Study of Identical Function Clones in CRAN
An Empirical Study of Identical Function Clones in CRANAn Empirical Study of Identical Function Clones in CRAN
An Empirical Study of Identical Function Clones in CRAN
 
Curriculum Vitae
Curriculum VitaeCurriculum Vitae
Curriculum Vitae
 
presentationIDC - 14MAY2015
presentationIDC - 14MAY2015presentationIDC - 14MAY2015
presentationIDC - 14MAY2015
 
Automating Environmental Computing Applications with Scientific Workflows
Automating Environmental Computing Applications with Scientific WorkflowsAutomating Environmental Computing Applications with Scientific Workflows
Automating Environmental Computing Applications with Scientific Workflows
 
H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215
 
AI Development with H2O.ai
AI Development with H2O.aiAI Development with H2O.ai
AI Development with H2O.ai
 
Machine learning key to your formulation challenges
Machine learning key to your formulation challengesMachine learning key to your formulation challenges
Machine learning key to your formulation challenges
 

Recently uploaded

Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
alex933524
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
theahmadsaood
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
AlejandraGmez176757
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 

Recently uploaded (20)

Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 

Making Software Refactorings Safer

  • 1. Making Software Refactorings Safer Anna Maria Eilertsen @Sowhow Supervised by: Anya Bagge1 Volker Stolz 2 1Inst. for Informatikk, Universitetet i Bergen 2Inst. for Data- og Realfag, Høgskolen i Bergen Norway July 12, 2016 The results of this thesis has been accepted to the ISOLA1 conference as a paper. 1 http://www.isola-conference.org/isola2016/ Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 1 / 14
  • 2. Software Refactorings “Behaviour preserving program transformation” Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 2 / 14
  • 3. Software Refactoring Tools Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 3 / 14
  • 4. Unsafe Refactorings “The primary risk is regression, mostly from misunderstanding subtle corner cases in the original code and not accounting for them in the refactored code.” – interviewee, Microsoft developer, Kim et al., 2012 Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 4 / 14
  • 5. Unsafe Refactoring Example Extract Local Variable In Java/Eclipse: Before 1 public void f() { 2 x.n(); 3 setX(); 4 x.n(); 5 } After 1 public void f() { 2 X temp = x; 3 temp.n(); 4 setX(); 5 temp.n(); 6 } Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 5 / 14
  • 6. An analysing problem x = new X(); setX(); // x = new X(); 1 public void f() { 2 X temp = x; 3 temp.n(); 4 setX(); 5 temp.n(); 6 } Solution: assert temp == x; ∗ Dog art from Hyperbole and a Half Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 6 / 14
  • 7. Extract Local Variable Simplified example: 1 public class C { 2 public X x = new X(); 3 {//initializer 4 x.myC = this; 5 } 6 7 public void f(){ 8 x.n(); 9 x.m(); 0 x.n(); 1 } 2 } 1 public class X{ 2 public C myC; 3 4 public void m(){ 5 myC.x = new X(); 6 } 7 8 public void n(){ 9 System.out.println( 10 this.hashCode()); 11 } 12 } Output: 1735600054 21685669 skip example Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 7 / 14
  • 8. Extract Local Variable Refactored: 1 public class C { 2 public X x = new X(); 3 {//initializer 4 x.myC = this; 5 } 6 7 public void f(){ 8 X temp = x; 9 temp.n(); 0 temp.m(); 1 temp.n(); 2 } 3 } 1 public class X{ 2 public C myC; 3 4 public void m(){ 5 myC.x = new X(); 6 } 7 8 public void n(){ 9 System.out.println( 10 this.hashCode()); 11 } 12 } Output: 1735600054 1735600054 Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 8 / 14
  • 9. Extract Local Variable With dynamic checks: 1 public class C { 2 public X x = new X(); 3 {//initializer 4 x.myC = this; 5 } 6 public void f(){ 7 X temp = x; 8 assert temp == x; 9 temp.n(); 0 assert temp == x; 1 temp.m(); 2 assert temp == x; 3 temp.n(); 1 public class X{ 2 public C myC; 3 4 public void m(){ 5 myC.x = new X(); 6 } 7 8 public void n(){ 9 System.out.println( 10 this.hashCode()); 11 } 12 } Output: 1735600054 Exception in thread ”main” java.lang.AssertionError Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 9 / 14
  • 10. Extract And Move Method A similar problem: 1 public class C { 2 public X x = new X(); 3 {//initializer 4 x.myC = this; 5 } 6 public void f(){ 7 x.bar(this); 8 } 9 } 1 public class X{ 2 ... 3 void bar(C c){ 4 this.n(); 5 assert this == c.x; 6 this.m(); 7 assert this == c.x; 8 this.n(); 9 } 10 } Similar how? Evaluate x once. Refer to that value by this Substitute every occurrence of x with this Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 10 / 14
  • 11. Experiment: Case study Case: Eclipse JDT UI source code Experiment: Execute our modified refactorings on Eclipse JDT UI project Run Eclipse test suite Look for triggered asserts Profit!! Need custom automated refactoring tool. Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 11 / 14
  • 12. Experiment: Results Extract Local Extract and Variable Move Method Executed refactorings 4538 755 Total number of asserts 7665 610 Resulting compile errors 0 14 Successful Tests 2392 2151 Unsuccessful Tests 4 245 Asserts triggered 2 / 136∗ 0 ∗ 136 instances of the same 2 assert statements Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 12 / 14
  • 13. Discussion Take-away and questions: Extract Local Extract and Variable Move Method Executed refactorings 4538 755 Total number of asserts 7665 610 Resulting compile errors 0 14 Successful Tests 2392 2151 Unsuccessful Tests 4 245 Asserts triggered 2 / 136 0 Dynamic preconditions can be useful! Assert statements are incomplete. Show or hide the asserts from the programmer? Is reference equivalence too strict? Thank you! ∗ Art with face is from Hyperbole and a Half Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 13 / 14
  • 14. Experiment: Development Eclipse refactoring plug-in Modify Eclipse’s refactorings to introduce asserts Extract Local Variable Extract And Move Method Automate refactoring process Execute on Java project One refactoring per method Custom heuristic for finding refactoring targets Anna Maria Eilertsen @sowhow (Inst. for Informatikk, Universitetet i Bergen, Inst. for Data-Making Software Refactorings Safer July 12, 2016 14 / 14