SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Making Software Refactorings Safer

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
 
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
Editor IJARCET
 
Computer Tools for Academic Research
Computer Tools for Academic ResearchComputer Tools for Academic Research
Computer Tools for Academic Research
Miklos Koren
 

Ähnlich wie 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
 
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
 
Using AI Planning to Automate the Performance Analysis of Simulators
Using AI Planning to Automate the Performance Analysis of SimulatorsUsing AI Planning to Automate the Performance Analysis of Simulators
Using AI Planning to Automate the Performance Analysis of Simulators
 

Kürzlich hochgeladen

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
gajnagarg
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
amitlee9823
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
only4webmaster01
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
amitlee9823
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
amitlee9823
 

Kürzlich hochgeladen (20)

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Rabindra Nagar  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Rabindra Nagar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Hsr Layout ☎ 7737669865 🥵 Book Your One night Stand
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night StandCall Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Nandini Layout ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men  🔝Bangalore🔝   Esc...
➥🔝 7737669865 🔝▻ Bangalore Call-girls in Women Seeking Men 🔝Bangalore🔝 Esc...
 

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