SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a Making Software Refactorings Safer with Dynamic Checks

Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2Boetticher Presentation Promise 2008v2
Boetticher Presentation Promise 2008v2gregoryg
 
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 & AlluxioAlluxio, 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 Architecturesinside-BigData.com
 
Introduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningIntroduction to Model-Based Machine Learning
Introduction to Model-Based Machine LearningDaniel Emaasit
 
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 pilotBigData_Europe
 
Correctness attraction __kth_2017
Correctness attraction __kth_2017Correctness attraction __kth_2017
Correctness attraction __kth_2017Benjamin Danglot
 
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 CRANTom Mens
 
Curriculum Vitae
Curriculum VitaeCurriculum Vitae
Curriculum VitaeAndy 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 WorkflowsRafael Ferreira da Silva
 
H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215H2ODeepLearningThroughExamples021215
H2ODeepLearningThroughExamples021215Sri Ambati
 
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 challengesMarc Borowczak
 
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 SimulatorsRoland Ewald
 

Semelhante a Making Software Refactorings Safer with Dynamic Checks (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
 

Último

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 

Último (20)

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 

Making Software Refactorings Safer with Dynamic Checks

  • 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