Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Exploring a Method to Detect Behaviour-Preservi...

Exploring a Method to Detect Behaviour-Preserving Evolution Using Graph Transformation

One of the problems of documenting software evolution appears with the extensive use of refactorings. This paper explores a method, based on graph transformation, to detect wether the evolution between two versions of a software system can be expressed by means of a sequence of refactoring operations. For this purpose we extend a graph representation format to use it for simple Java programs, and we show a sample implementation of the method using the AGG graph transformation tool. In case a refactoring sequence exists, our technique can help reveal the functional equivalence between the two versions of the system, at least, as far as refactorings can assure behaviour preservation. Presented in 2007 at the Third International ERCIM Symposium on Software Evolution (http://ercim-news.ercim.eu/en72/joint-ercim-actions/third-international-ercim-symposium-on-software-evolution).

Javier Pérez

October 05, 2007
Tweet

More Decks by Javier Pérez

Other Decks in Research

Transcript

  1. Exploring a Method to Detect Behaviour-Preserving Evolution Using Graph Transformation

    Javier Pérez, Yania Crespo {jperez,yania}@infor.uva.es Universidad de Valladolid Third International ERCIM Symposium on Software Evolution (co-located with ICSM 2007) Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 1 / 36
  2. Introduction Introduction: Context Refactorings are commonly integrated into development environments

    and are extensively used. Finding and understanding refactorings is important to document and to understand a system’s evolution. It will be useful to determine automatically when software evolution has been behaviour-preserving. to verify a redesign process to verify a handmade refactoring to find and characterise stages of a system’s evolution . . . Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 2 / 36
  3. Introduction Introduction: Goals To detect whether two versions of a

    software system are functionally equivalent, by checking whether the evolution process between this two versions can be formulated by a refactoring sequence n n + 1 Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 3 / 36
  4. Introduction Introduction: Goals To detect whether two versions of a

    software system are functionally equivalent, by checking whether the evolution process between this two versions can be formulated by a refactoring sequence n n + 1 R 1 R 2 R n Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 3 / 36
  5. Introduction Introduction: Approach We are exploring a method which: uses

    a graph representation format for Java programs and Java refactorings, models the problem as a state space search, searches sequences of ONLY refactorings, uses refactorings’ pre and postconditions to guide the search. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 4 / 36
  6. Introduction Introduction: Approach We are exploring a method which: uses

    a graph representation format for Java programs and Java refactorings, models the problem as a state space search, searches sequences of ONLY refactorings, uses refactorings’ pre and postconditions to guide the search. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 4 / 36
  7. Introduction Introduction: Approach We are exploring a method which: uses

    a graph representation format for Java programs and Java refactorings, models the problem as a state space search, searches sequences of ONLY refactorings, uses refactorings’ pre and postconditions to guide the search. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 4 / 36
  8. Introduction Introduction: Approach We are exploring a method which: uses

    a graph representation format for Java programs and Java refactorings, models the problem as a state space search, searches sequences of ONLY refactorings, uses refactorings’ pre and postconditions to guide the search. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 4 / 36
  9. Short Example: Printing system Example: Simulation of a Printing System

    PrinterHub printWithPDF(p:PDFPrinter) Printer content: String setContent(c:String) printDefault() PDFPrinter printPDF() Different printers for different document types and a printer hub to connect all the printers. More printers will be added when needed. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 5 / 36
  10. Short Example: Printing system Example: Refactored Printing System PrinterHub print(p:Printer)

    Printer content: String setContent(c:String) print() The system administrator noticed that only pdf documents were sent. Rashly modification to simplify the inheritance hierarchy. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 6 / 36
  11. Short Example: Printing system Problem! A new system administrator arrives.

    Finds two versions of the system, and no documentation about the changes performed between them. Problems: documenting the changes performed to the old system is the new system functionally equivalent to the old one? We know that a sequence exists (done manually). Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 7 / 36
  12. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  13. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  14. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  15. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  16. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  17. Short Example: Printing system Refactoring Sequence Applied 1 removeMethod: printing.Printer.printDefault()

    2 pullUpMethod: printing.PDFPrinter.printPDF() =⇒ printing.Printer.printPDF() 3 renameMethod: printing.Printer.printPDF() =⇒ printing.Printer.print() 4 renameMethod: printing.PrinterHub.printWithPDF() =⇒ printing.PrinterHub.print() 5 useSuperType: printing.Printer.print(PDFPrinter p) =⇒ printing.Printer.print(Printer p) 6 removeClass: printing.PDFPrinter Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 8 / 36
  18. Graph Representation Refactorings and Graph Transformation We use Graph Transformation

    as a formal representation for refactorings and OO software GT deals with structure representation and modification refactorings are structural modifications We use the work of Mens et al. “Formalising Refactorings with Graph Transformations” as our basis, to represent: programs as graphs refactorings as graph transformation rules We have made a small extension to this format to represent simple Java programs. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 9 / 36
  19. Graph Representation Refactorings and Graph Transformation We use Graph Transformation

    as a formal representation for refactorings and OO software GT deals with structure representation and modification refactorings are structural modifications We use the work of Mens et al. “Formalising Refactorings with Graph Transformations” as our basis, to represent: programs as graphs refactorings as graph transformation rules We have made a small extension to this format to represent simple Java programs. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 9 / 36
  20. Graph Representation Original Printing System //------------------------PrinterHub.java public class PrinterHub {

    public void printWithPDF(PDFPrinter p){ p.printPDF(); } } //------------------------PDFPrinter.java public class PDFPrinter extends Printer{ public void printPDF(){ // body of printPDF method } } //---------------------------Printer.java public class Printer { public String content; public void setContent(String c){ this.content = c; } public void printDefault(){ // body of printDefault method } } Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 10 / 36
  21. Graph Representation Original Printing System Graph Javier Pérez (Universidad de

    Valladolid) Detecting Behaviour-Preserving Evolution October 2007 11 / 36
  22. Graph Representation Refactorings as Graph Transformation Rules Left-hand side: Rule

    precondition. Can be used to express refactorings’ pre and postconditions. Rigth-hand side: Transformation. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 12 / 36
  23. Searching Method Modeling the problem We address the problem as

    a state space search problem: Original/Old system ≃ start state. Refactoring operations ≃ state changing operations, edges. Refactored/New system ≃ goal state. Does a refactoring sequence exist? ≃ reachability problem. Refactoring sequence ≃ path from the start state to the goal state. We apply a graph parsing algorithm to perform depth-first search Main problem: size of the state space (finite?) With refactoring descriptions expressed in terms of preconditions, transformations and postconditions, preconditions and postconditions can guide the search, we can reduce the size of the state space. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 13 / 36
  24. Searching Method Modeling the problem We address the problem as

    a state space search problem: Original/Old system ≃ start state. Refactoring operations ≃ state changing operations, edges. Refactored/New system ≃ goal state. Does a refactoring sequence exist? ≃ reachability problem. Refactoring sequence ≃ path from the start state to the goal state. We apply a graph parsing algorithm to perform depth-first search Main problem: size of the state space (finite?) With refactoring descriptions expressed in terms of preconditions, transformations and postconditions, preconditions and postconditions can guide the search, we can reduce the size of the state space. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 13 / 36
  25. Searching Method Modeling the problem We address the problem as

    a state space search problem: Original/Old system ≃ start state. Refactoring operations ≃ state changing operations, edges. Refactored/New system ≃ goal state. Does a refactoring sequence exist? ≃ reachability problem. Refactoring sequence ≃ path from the start state to the goal state. We apply a graph parsing algorithm to perform depth-first search Main problem: size of the state space (finite?) With refactoring descriptions expressed in terms of preconditions, transformations and postconditions, preconditions and postconditions can guide the search, we can reduce the size of the state space. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 13 / 36
  26. Searching Method Algorithm Target Source 0 R1 R2 R3 R4

    Available Refactorings Refactoring Sequence Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 14 / 36
  27. Searching Method Algorithm Target Source 0 R1 R2 R3 R4

    Available Refactorings Refactoring Sequence Pre Post Post Post R1 R3 Pre Looks for refactoring preconditions in the start graph. Looks for refactoring postconditions in the goal graph. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 15 / 36
  28. Searching Method Algorithm Target Source 1 R1 R2 R3 R4

    Available Refactorings R1 Refactoring Sequence Pre Post Post R1 Post R3 Pre Iteratively selects candidate refactorings Transforms the current graph with them Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 16 / 36
  29. Searching Method Algorithm Target Source 2 R1 R2 R3 R4

    Available Refactorings R1 R1 Refactoring Sequence Post R4 Pre Post R3 Pre Iteratively selects candidate refactorings Transforms the current graph with them Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 17 / 36
  30. Searching Method Algorithm Target Source 3 R1 R2 R3 R4

    Available Refactorings R1 R1 R3 Refactoring Sequence Pre Post R2 Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 18 / 36
  31. Searching Method Algorithm Target Source 4 R1 R2 R3 R4

    Available Refactorings R1 R1 R3 R2 Refactoring Sequence Success: current graph isomorphic to the goal graph, Fail: No more refactorings can be executed, current and goal states are not isomorphic. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 19 / 36
  32. Implementation in AGG Implementation in AGG Easy to use graph

    transformation tool AGG allows rapid prototyping of GT systems. It supports graph parsing, which can be used to perform the search: The AGG parser randomly applies rules to the start graph until it is isomorphic to the goal graph, or no more rules are available, and backtracking is no longer possible. AGG allows to “exercise” our approach easily. It present expressiveness and efficiency limitations. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 20 / 36
  33. Implementation in AGG Implementation in AGG Easy to use graph

    transformation tool AGG allows rapid prototyping of GT systems. It supports graph parsing, which can be used to perform the search: The AGG parser randomly applies rules to the start graph until it is isomorphic to the goal graph, or no more rules are available, and backtracking is no longer possible. AGG allows to “exercise” our approach easily. It present expressiveness and efficiency limitations. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 20 / 36
  34. Running the Example Running the Example Set of rules to

    search: pullUpMethod, renameMethod, removeMethod, removeClass, removeInterface and useSuperType Each iteration, among candidate rules: AGG selects randomly one to apply it. AGG backtracks when needed and possible. Output from the AGG parser’s debugging information: rules applied when backtracking occurs intermediate graphs . . . parsing takes about 2 seconds Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 21 / 36
  35. Running the Example Running the Example Set of rules to

    search: pullUpMethod, renameMethod, removeMethod, removeClass, removeInterface and useSuperType Each iteration, among candidate rules: AGG selects randomly one to apply it. AGG backtracks when needed and possible. Output from the AGG parser’s debugging information: rules applied when backtracking occurs intermediate graphs . . . parsing takes about 2 seconds Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 21 / 36
  36. Running the Example State Space, Derivation Graph 0 / S

    o u r c e 2 r e m o v e M e t h o d ( p r i n t D e f a u l t ) 7 1 2 p u l l U p M e t h o d ( p r i n t P D F ) r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) 1 4 r e m o v e M e t h o d ( p r i n t W i t h P D F ) r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) F A I L S U C C E S S 2 3 2 5 26 / Target u s e S u p e r T y p e r e m o v e C l a s s ( P D F P r i n t e r ) 8 1 3 p u l l U p M e t h o d ( p r i n t P D F ) S T A R T r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) For this experiment, the parsing terminates and finds a sequence. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 22 / 36
  37. Running the Example State Space, Derivation Graph 0 / S

    o u r c e 2 r e m o v e M e t h o d ( p r i n t D e f a u l t ) 7 1 2 p u l l U p M e t h o d ( p r i n t P D F ) r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) 1 4 r e m o v e M e t h o d ( p r i n t W i t h P D F ) r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) F A I L S U C C E S S 2 3 2 5 26 / Target u s e S u p e r T y p e r e m o v e C l a s s ( P D F P r i n t e r ) 8 1 3 p u l l U p M e t h o d ( p r i n t P D F ) S T A R T r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) For this experiment, the parsing terminates and finds a sequence. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 22 / 36
  38. Running the Example State Space, Derivation Graph 0 / S

    o u r c e 2 r e m o v e M e t h o d ( p r i n t D e f a u l t ) 7 1 2 p u l l U p M e t h o d ( p r i n t P D F ) r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) 1 4 r e m o v e M e t h o d ( p r i n t W i t h P D F ) r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) p u l l U p M e t h o d ( p r i n t P D F ) 9 1 6 r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) F A I L S U C C E S S 2 3 r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) 2 5 26 / Target u s e S u p e r T y p e r e m o v e C l a s s ( P D F P r i n t e r ) 8 1 3 p u l l U p M e t h o d ( p r i n t P D F ) S T A R T r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) The first sequence found differs from the one found manually Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 23 / 36
  39. Running the Example State Space, Derivation Graph 0 / S

    o u r c e 2 r e m o v e M e t h o d ( p r i n t D e f a u l t ) 7 1 2 p u l l U p M e t h o d ( p r i n t P D F ) r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) 1 4 r e m o v e M e t h o d ( p r i n t W i t h P D F ) r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) p u l l U p M e t h o d ( p r i n t P D F ) 9 1 6 r e n a m e M e t h o d ( p r i n t P D F , p r i n t ) F A I L S U C C E S S 2 3 r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) 2 5 26 / Target u s e S u p e r T y p e r e m o v e C l a s s ( P D F P r i n t e r ) 8 1 3 p u l l U p M e t h o d ( p r i n t P D F ) S T A R T r e n a m e M e t h o d ( p r i n t W i t h P D F , p r i n t ) The first sequence found differs from the one found manually Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 23 / 36
  40. Running the Example State Space, Derivation Graph 0 / Source

    2 3 5 removeMethod(printDefault) renameMethod(printDefault, print) pullUpMethod(printPDF) 4 renameMethod(printWithPDF, print) 7 12 1 removeMethod(printWithPDF) removeMethod(printDefault) pullUpMethod(printPDF) renameMethod(printPDF, print) 14 6 pullUpMethod(printPDF) removeMethod(printDefault) removeMethod(printWithPDF) renameMethod(printWithPDF, print) pullUpMethod(printPDF) 9 16 renameMethod(printPDF, print) FAIL SUCCESS 23 renameMethod(printWithPDF, print) 25 26 / Target useSuperType removeClass(PDFPrinter) removeMethod(printWithPDF) 8 13 pullUpMethod(printPDF) useSuperType 15 19 20 removeClass(PDFPrinter) renameMethod(printPDF, print) renameMethod(printPDF, print) removeClass(PDFPrinter) 10 11 removeMethod(printWithPDF) renameMethod(printWithPDF, print) 18 pullUpMethod(printPDF) 22 useSuperType 24 removeClass(PDFPrinter) FAIL 17 pullUpMethod(printPDF) FAIL START renameMethod(printWithPDF, print) We can obtain the whole state space. In this case, it is finite. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 24 / 36
  41. Discussion Our results There are not many works dealing with

    finding refactorings. These efforts focus in mining refactorings mixed with other changes. We focus on the detection of behaviour-preserving evolution. Changes are only refactorings. We can deal with multiple refactoring changes applied to the same piece of code. We can deal with renamings. The structural representation can be as detailed as needed to support refactorings at any abstraction level. We have explored the possibilities of our approach. Many ways of improving it to solve the open problems. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 25 / 36
  42. Discussion Our results There are not many works dealing with

    finding refactorings. These efforts focus in mining refactorings mixed with other changes. We focus on the detection of behaviour-preserving evolution. Changes are only refactorings. We can deal with multiple refactoring changes applied to the same piece of code. We can deal with renamings. The structural representation can be as detailed as needed to support refactorings at any abstraction level. We have explored the possibilities of our approach. Many ways of improving it to solve the open problems. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 25 / 36
  43. Discussion Our results There are not many works dealing with

    finding refactorings. These efforts focus in mining refactorings mixed with other changes. We focus on the detection of behaviour-preserving evolution. Changes are only refactorings. We can deal with multiple refactoring changes applied to the same piece of code. We can deal with renamings. The structural representation can be as detailed as needed to support refactorings at any abstraction level. We have explored the possibilities of our approach. Many ways of improving it to solve the open problems. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 25 / 36
  44. Discussion Problems and Limitations: Termination Problem: Our searching algorithm is

    only partially correct. If the state space is not finite the termination can not be guaranteed. Solutions: Use of refactorings’ pre and postconditions Formulate the searching rules to limit the search space size. Store states to not check the same state twice. More heuristics. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 26 / 36
  45. Discussion Problems and Limitations: Termination Problem: Our searching algorithm is

    only partially correct. If the state space is not finite the termination can not be guaranteed. Solutions: Use of refactorings’ pre and postconditions Formulate the searching rules to limit the search space size. Store states to not check the same state twice. More heuristics. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 26 / 36
  46. Discussion Problems and Limitations: expressiveness Problem: We have not implemented

    “real” refactoring operations. AGG lacks some key features needed, path expressions. Representing context: Limitation to a single, finite context. We need to specify a set of contexts. Solution: Test more GT tools (PROGRES, GROOVE, . . . ). Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 27 / 36
  47. Discussion Problems and Limitations: expressiveness Problem: We have not implemented

    “real” refactoring operations. AGG lacks some key features needed, path expressions. Representing context: Limitation to a single, finite context. We need to specify a set of contexts. Solution: Test more GT tools (PROGRES, GROOVE, . . . ). Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 27 / 36
  48. Discussion Problems and Limitations: Complex Refactorings Problem: Difficult to represent

    rules for refactorings which take an undetermined number of steps. Lack of a full transformation control in AGG, Solutions: Last versions of AGG implement a better execution control. Program the rule control and use AGG as a backend rule execution engine. Test more GT tools (PROGRES, GROOVE, . . . ). Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 28 / 36
  49. Discussion Problems and Limitations: Complex Refactorings Problem: Difficult to represent

    rules for refactorings which take an undetermined number of steps. Lack of a full transformation control in AGG, Solutions: Last versions of AGG implement a better execution control. Program the rule control and use AGG as a backend rule execution engine. Test more GT tools (PROGRES, GROOVE, . . . ). Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 28 / 36
  50. Future Work Future Work Analysis of the state space: Can

    we formulate the refactoring searching rules to restrict the search space to a finite state space? Searching rule catalog: Improving rules with features in the newest AGG’s versions. Implementing rules to search more refactorings. Test other GT tools: To improve efficiency, expressiveness, . . . Full Java model: Use another metamodel which can represent full Java programs. Scalability: Measuring the scalability and reliability of our technique over industrial-size systems. Tool: Eclipse plugin front-end to translate code to graphs, to launch AGG and to show up the refactoring sequence in a more convenient way. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 29 / 36
  51. Thanks for your attention! Exploring a Method to Detect Behaviour-Preserving

    Evolution Using Graph Transformation Javier Pérez, Yania Crespo {jperez,yania}@infor.uva.es Universidad de Valladolid Third International ERCIM Symposium on Software Evolution (co-located with ICSM 2007) Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 30 / 36
  52. Bonus slides! Implementation: renameMethod (a) Rule: rename method (b) NAC:

    New name not exists in source (c) NAC: Old name not exists in target (d) Attribute con- dition: old name is not equal to new name Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 31 / 36
  53. Bonus slides! Host and Stop Graphs (a) Host graph (original

    system) (b) Stop graph (refactored system) Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 32 / 36
  54. Bonus slides! Parsing S G S1 S2 G G T

    G Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 33 / 36
  55. Bonus slides! Demeyer et al. “Finding refactorings via change metrics”

    Use metrics to reveal refactorings. Does not behave well with renamings. Looses effectiveness when many changes have been applied to the same piece of code. We can deal with multiple refactoring changes. We can deal with renamings. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 34 / 36
  56. Bonus slides! Görg and Weißgerber “Detecting and visualizing refactorings from

    software archives” Find refactorings from consecutive transactions in CVS repositories. This work is based in pairing and comparing elements (classes and methods) between transactions, using element attributes such as name, parameters, return type, visibility, etc. The method presents good empirical results, but can not detect refactorings when more than one change has been applied to a program elemen Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 35 / 36
  57. Bonus slides! Dig et al. “Automatic detection of refactorings in

    evolving components” Good empirical results. Based on comparing lexycographic proximity. Oriented to changes in the API. It can not deal with lower abstraction level changes, within method bodies. Our structural representation can be as detailed as needed to support refactorings at any abstraction level. Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 36 / 36