Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Graph Representation Original Printing System Graph Javier Pérez (Universidad de Valladolid) Detecting Behaviour-Preserving Evolution October 2007 11 / 36

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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