Identifying overly strong conditions                in refactoring implementations                                        ...
Employee                                            ...                                      Salesman               Engine...
Pull Up Field Refactoring                                                Refactoring                        Employee      ...
It’s difficult to specify and                          implement preconditions                                     precondi...
Problem               Overly	  strong	  condi0ons               prevent	  safe	                 transforma+ons            ...
Motivating example                                     A                                               JRRT               ...
A                       Overly strong                                         JRRT                                        ...
Identifying overly strong                      conditions                       An evaluation on 3 refactoring engines    ...
Testing                                             input                                            expected             ...
Testing                                      input                  engine                                     expected   ...
Exhaustively generating programs        input     Overly     Strong                          Differential testing   condit...
2 Class, 2 Method, 2 Field                                     One subclass declaring a field                              ...
2 Class, 2 Method, 2 Field                                     One subclass declaring a field       Java Meta model        ...
Exhaustively generating programs        input    expected     output                          Differential testing        ...
B.getF                   A                                                          A                                     ...
Classifying                    overly strong                   preconditionsTechnique                    Differential     ...
Classifying overly strong                     conditions   A.test	  cannot	  access	  method	  A.k                        ...
Evaluation                                         18terça-feira, 11 de outubro de 2011
Up to 10 refactorings                           Refactoring   Eclipse   JRRT   NetBeans                       Rename Class...
Results                                                    Rejected Beh. Pres.     Overly Strong Condition        Refactor...
JRRT feedback                          Refactoring               Strong conditions                          Rename Method ...
JRRT feedback     Refactoring                            Strong conditions                                    Cause      R...
Conclusions     Differential       Testing                  +                    Implemented                              ...
Identifying overly strong conditions                in refactoring implementations                                        ...
Upcoming SlideShare
Loading in …5
×

Migration and Refactoring - Identifying Overly Strong Conditions in Refactoring Implementations

849 views
823 views

Published on

Paper: Identifying Overly Strong Conditions in Refactoring Implementations

Authors: Gustavo Soares, Melina Mongiovi and Rohit Gheyi

Session: Research Track Session 6: Migration and Refactoring

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
849
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Migration and Refactoring - Identifying Overly Strong Conditions in Refactoring Implementations

  1. 1. Identifying overly strong conditions in refactoring implementations Gustavo Soares Melina Mongiovi Rohit Gheyi gsoares@dsc.ufcg.edu.br Federal University of Campina Grandeterça-feira, 11 de outubro de 2011
  2. 2. Employee ... Salesman Engineer ... ... name name Duplicated code 2terça-feira, 11 de outubro de 2011
  3. 3. Pull Up Field Refactoring Refactoring Employee engines Employee ... ... name Salesman Engineer ... ... Salesman Engineer name name ... ... Precondition The name field is not declared in class Employee 3terça-feira, 11 de outubro de 2011
  4. 4. It’s difficult to specify and implement preconditions preconditions 4terça-feira, 11 de outubro de 2011
  5. 5. Problem Overly  strong  condi0ons prevent  safe   transforma+ons Implemented preconditions Overly  weak condi0ons  allow unsafe  transforma+ons 5terça-feira, 11 de outubro de 2011
  6. 6. Motivating example A JRRT GetF() cannot access B variable f Pull up field private int f int getF() : f 6terça-feira, 11 de outubro de 2011
  7. 7. A Overly strong JRRT GetF() cannot access B variable f Pull up field private int f int getF() : f A A protected int f B B Pull up field private int f int getF() : f int getF() : f 7terça-feira, 11 de outubro de 2011
  8. 8. Identifying overly strong conditions An evaluation on 3 refactoring engines JRRT 8terça-feira, 11 de outubro de 2011
  9. 9. Testing input expected output 9terça-feira, 11 de outubro de 2011
  10. 10. Testing input engine expected output output Overly strong 10terça-feira, 11 de outubro de 2011
  11. 11. Exhaustively generating programs input Overly Strong Differential testing conditions Overly Strong Condition 11terça-feira, 11 de outubro de 2011
  12. 12. 2 Class, 2 Method, 2 Field One subclass declaring a field 12terça-feira, 11 de outubro de 2011
  13. 13. 2 Class, 2 Method, 2 Field One subclass declaring a field Java Meta model Alloy Solutions Java programs public class Class0 { public int method2(){ { { public class Class0 public class Class0 public int method2(){ return 10; public int method2(){ } return 10; return 10; } }} } class Class1 extends Class0 { } class Class1 extends Class0 { public int method1(){ Class0 { class Class1 extends public int method1(){ return 20; method1(){ public int } return 20; } return 20; public int method2(){ } public int method2(){ super.k(); method2(){ public int } super.k(); super.k(); } }} } } 13terça-feira, 11 de outubro de 2011
  14. 14. Exhaustively generating programs input expected output Differential testing Overly Strong Condition 14terça-feira, 11 de outubro de 2011
  15. 15. B.getF A A protected int f B B 0/4 0/4 private int f int getF() : f int getF() : f 4 No behavioral change was found 15terça-feira, 11 de outubro de 2011
  16. 16. Classifying overly strong preconditionsTechnique Differential testing 16 terça-feira, 11 de outubro de 2011 SPEC
  17. 17. Classifying overly strong conditions A.test  cannot  access  method  A.k OTC B.m  cannot  access  method  B.n cannot  access  method C.test  cannot  access  method  C.k 17terça-feira, 11 de outubro de 2011
  18. 18. Evaluation 18terça-feira, 11 de outubro de 2011
  19. 19. Up to 10 refactorings Refactoring Eclipse JRRT NetBeans Rename Class X X X Rename Method X X X Rename Field X X X Push Down Method X X X Push Down Field X X X Pull Up Method X X X Pull Up Field X X X Encapsulate Field X X Move Method X X Add Parameter X X 2 Packages, 3 classes, 4 methods, 2 fields 19terça-feira, 11 de outubro de 2011
  20. 20. Results Rejected Beh. Pres. Overly Strong Condition Refactoring Program Ecl JRRT NetB Ecl JRRT NetB Rename Class 4660 446 0 0 2 0 0 Rename Method 4752 4802 419 0 4 1 0 Rename Field 3168 200 0 0 2 0 0 Push Down Method 9366 59 40 0 1 1 0 Push Down Field 4800 0 0 0 0 0 0 Pull Up Method 10322 251 398 0 2 2 0 Pull Up Field 4320 744 584 0 1 1 0 Encapsulate Field 900 176 1536 - 1 1 - Move Method 3002 367 135 - 2 1 - Add Parameter 4279 79 0 - 2 0 - Total 42774 7124 3112 0 17 7 0 20terça-feira, 11 de outubro de 2011
  21. 21. JRRT feedback Refactoring Strong conditions Rename Method overriding  has  changed Push Down Method cannot  access  method method  is  used Pull Up Method cannot  access  method Pull Up Field cannot  access  variable   Encapsulate Field cannot  insert  method  here Move Method cannot  inline  ambiguous  method  call 21terça-feira, 11 de outubro de 2011
  22. 22. JRRT feedback Refactoring Strong conditions Cause Rename Method overriding  has  changed precondi+on Push Down Method cannot  access  method incorrect  analysis method  is  used incorrect  analysis Pull Up Method cannot  access  method incorrect  analysis Pull Up Field cannot  access  variable   feature  not  implemented Encapsulate Field cannot  insert  method  here feature  not  implemented Move Method cannot  inline  ambiguous  method  call incorrect  analysis 22terça-feira, 11 de outubro de 2011
  23. 23. Conclusions Differential Testing + Implemented preconditions overly strong conditions + overly weak conditions 23terça-feira, 11 de outubro de 2011
  24. 24. Identifying overly strong conditions in refactoring implementations Gustavo Soares Melina Mongiovi Rohit Gheyi gsoares@dsc.ufcg.edu.br Federal University of Campina Grande 24terça-feira, 11 de outubro de 2011

×