IBM Haifa Research Lab © 2007 IBM Corporation Refactoring via Program Slicing and Sliding June 2007 Ran Ettinger Software Asset Management Group In HRL.

Slides:



Advertisements
Similar presentations
Semantic Business Management November 5, 2009 Paul Haley Automata, Inc. (412)
Advertisements

A Probabilistic Representation of Systemic Functional Grammar Robert Munro Department of Linguistics, SOAS, University of London.
Software Re-engineering
Software Re-engineering
Chapter 11 Introduction to Programming in C
IBM Haifa Research Lab © 2008 IBM Corporation Co-Slicing for Program Comprehension and Reuse March 2008 Ran Ettinger Software Asset Management Group In.
IBM Haifa Research Lab © 2007 IBM Corporation Program Sliding A Novel Approach for the Automation of Slicing-Based Refactoring June 2007 Ran Ettinger In.
Refactoring via Program Slicing and Sliding Ran Ettinger Programming Tools Group University of Oxford In Panayas Reading Group 2 November, 2006.
Copyright © 2006 Data Access Technologies, Inc. Open Source eGovernment Reference Architecture Approach to Semantic Interoperability Cory Casanave, President.
Lecture 1 Welcome COMP1681 / SE15 Introduction to Programming.
© Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn 2.4 The Z Notation [Reference: M. Spivey: The Z Notation, Prentice Hall]
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Lecture 6: Software Design (Part I)
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
This work was partially funded by the RNTL initiative (LUTIN project) 1 Refactoring to Object-Oriented Design Patterns Mikal Ziane (LIP6 and Université.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 20 Systems Operations and Support.
14-1 © Prentice Hall, 2004 Chapter 14: OOSAD Implementation and Operation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh.
Overview Structural Testing Introduction – General Concepts
Program Slicing – Based Techniques
1 Translation Validation: From Simulink to C Michael RyabtsevOfer Strichman Technion, Haifa, Israel Acknowledgement: sponsored by a grant from General.
 Program Slicing Long Li. Program Slicing ? It is an important way to help developers and maintainers to understand and analyze the structure.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
A survey of techniques for precise program slicing Komondoor V. Raghavan Indian Institute of Science, Bangalore.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
VIDE als voortzetting van Cocktail SET Seminar 11 september 2008 Dr. ir. Michael Franssen.
ISBN Chapter 3 Describing Syntax and Semantics.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Supported by: Joint MSc curriculum in software engineering European Union TEMPUS Project CD_JEP New Topics for Software Evolution Miloš Radovanović.
VIDE Integrated Environment for Development and Verification of Programs.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
CMPUT Compiler Design and Optimization1 CMPUT680 - Winter 2006 Topic H: SSA for Predicated Code José Nelson Amaral
Program Slicing for Refactoring Advanced SW Tools Seminar Jan 2005Yossi Peery.
Describing Syntax and Semantics
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Deriving AO Software Architectures using the AO-ADL Tool Suite Luis Fernández, Lidia Fuentes, Mónica Pinto, Juan A. Valenzuela Universidad de Málaga
A Survey of Software Refactoring Tom Mens, Tom Tourwé
Ontology Development Kenneth Baclawski Northeastern University Harvard Medical School.
C++ Code Analysis: an Open Architecture for the Verification of Coding Rules Paolo Tonella ITC-irst, Centro per la Ricerca Scientifica e Tecnologica
1 TRex Paul Baker 1, Dominic Evans 1, Jens Grabowski 2, Helmut Neukirchen 2, Benjamin Zeiss 2 The Refactoring and Metrics Tool for TTCN-3 Test Specifications.
GLOSSARY COMPILATION Alex Kotov (akotov2) Hanna Zhong (hzhong) Hoa Nguyen (hnguyen4) Zhenyu Yang (zyang2)
IBM Haifa Research Lab © 2008 IBM Corporation Automating Big Refactorings for Componentization and the Move to SOA IBM Programming Languages and Development.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
ASPfun: A Distributed Object Calculus and its Formalization in Isabelle Work realized in collaboration with Florian Kammüller and Henry Sudhof (Technische.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 28Slide 1 CO7206 System Reengineering 4.2 Software Reengineering Most slides are Slides.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM.
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
Program Slicing Techniques CSE 6329 Spring 2013 Parikksit Bhisay
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
© 2004 Pearson Addison-Wesley. All rights reserved January 23, 2006 Creating Objects & String Class ComS 207: Programming I (in Java) Iowa State University,
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Lecture 1 Introduction Richard Gesick.
Proof Carrying Code and Proof Preserving Program Transformations
Ran Ettinger, IBM Research – Haifa Beijing, China 16 June 2012
Program Sliding Ran Ettinger, IBM Research – Haifa
Creating Objects & String Class
SwE 455 Program Slicing.
Program comprehension during Software maintenance and evolution Armeliese von Mayrhauser , A. Marie Vans Colorado State University Summary By- Fardina.
Mark Weiser University of Maryland, College Park IEEE CHI, 1981
Towards Automatic Model Synchronization from Model Transformation
Chapter 1 Introduction(1.1)
POWERPOINT PRESENTATION
Presentation transcript:

IBM Haifa Research Lab © 2007 IBM Corporation Refactoring via Program Slicing and Sliding June 2007 Ran Ettinger Software Asset Management Group In HRL Seminar

IBM Haifa Research Lab © 2007 IBM Corporation 2 Agenda When Refactoring Met Slicing… Motivating example and some definitions Original Research Question (2001) –How can program slicing and related analyses assist in building automatic tools for refactoring? Initial Results (2003) Untangling: a slice extraction refactoring [AOSD04] The need for more… Final Results (2006) Sliding on top of a formal theory for slicing-based refactoring... Some Further Challenges

IBM Haifa Research Lab © 2007 IBM Corporation 3 When Refactoring Met Slicing… Refactoring is a discipline of change –Of the internal structure of a software system –Through small and well-defined source-code transformations –That preserve the (observable) behavior of the original system (program) –Demo 1: Refactoring in Eclipse Slicing is the study of meaningful subprograms When debugging unfamiliar programs programmers use program pieces called slices which are sets of statements related by their flow of data. The statements in a slice are not necessarily textually contiguous, but may be scattered through a program [Mark Weiser, CACM82 ] Given a program and a variable (at a point) of interest, a slice of the program on that variable is a subprogram that preserves the original behavior, with respect to that variable Demo 2: Slicing in Eclipse

IBM Haifa Research Lab © 2007 IBM Corporation 4 When Refactoring Met Slicing… Refactoring is a discipline of change –Of the internal structure of a software system –Through small and well-defined source-code transformations –That preserve the (observable) behavior of the original system (program) –Demo 1: Refactoring in Eclipse Slicing is the study of meaningful subprograms –When debugging unfamiliar programs programmers use program pieces called slices which are sets of statements related by their flow of data. The statements in a slice are not necessarily textually contiguous, but may be scattered through a program [Mark Weiser, CACM82 ] –Given a program and a variable (at a point) of interest, a slice of the program on that variable is a subprogram that preserves the original behavior, with respect to that variable –Demo 2: Slicing in Eclipse

IBM Haifa Research Lab © 2007 IBM Corporation 5 Original Research Question Initial observation: –Programmers use slices when refactoring Paraphrasing Weiser [CACM82] Context –Intercomps Cobol-to-Java –OOPSLA00 –Fowlers refactoring book [Fow] The video-store example: from procedural design to objects The research question: –How can program slicing and related analyses assist in building automatic tools for refactoring?

IBM Haifa Research Lab © 2007 IBM Corporation 6 Initial Results (1) A definition of an Extract Slice mini refactoring –Given a program and a variable (at a point) of interest, extract the slice of the program on that variable as a reusable method, and update the original program to reuse the extracted slice –Can participate in solving Extract Method, Replace Temp with Query, and other known refactorings Nate: an Eclipse plugin for slice ectraction –Supporting slice extraction on a small subset of Java –Supported by an Eclipse Innovation Grant from IBM –Implemented with Mathieu Verbaere: the slicer and MSc thesis –Demo 3: The Replace Temp with Query refactoring in Eclipse+Nate An investigation of untangling refactorings to introduce aspects Untangling: a slice extraction refactoring [AOSD04, with Mathieu]

IBM Haifa Research Lab © 2007 IBM Corporation 7 Initial Results (2): The Need for More State-of-the-art slice-extraction solutions –Block-based slicing by Maruyama [SSR01] –Tucking by Lakhotia and Deprez [IST98] –Procedure extraction by Komondoor and Horwitz [POPL00,IWPC03] Identified limitations (Nate and the related work) –Strong preconditions E.g. no duplication of assignments Leading to low applicability –Informal (unconvincing) correctness proof Observation/Realization: –Weakening of preconditions (i.e. improving applicability) will require a careful (preferably formal) investigation

IBM Haifa Research Lab © 2007 IBM Corporation 8 Final Results (1) A formal theory of slicing-based refactoring –Based on predicate calculus and program semantics [Dijkstra and Scholten] and the refinement calculus [Back,Morgan] –Supporting a simple imperative programming language A designated slice-refinement proof method –Separate correctness proofs for extracted slice and complement –Together yield full refinement (i.e. correctness) –Works only for deterministic programs! No problem: Refactoring deals with executable code, not specifications

IBM Haifa Research Lab © 2007 IBM Corporation 9 Final Results (2) A novel program decomposition into small entities called slides –Smaller than slices: Ignore data flow influences –Participates in the formation of (potentially) smaller complements A highly applicable solution to the slice-extraction refactoring problem, called sliding –A kind of code-motion transformation, like in compilers –Trading code reusability and readability with runtime efficiency –Given a program and a variable of interest, sliding extracts the variables slice from its complement; but whats in the complement? The union of all remaining slices? No. Its a union of slides: Reusing the extracted variables final value

IBM Haifa Research Lab © 2007 IBM Corporation 10 Final Results (3) A concept of smaller slices called co-slicing –A co-slice is made of a (meaningful) set of slides A provably correct slicing algorithm –Based on the static-single-assignment (SSA) form –A slice is made of a set of slides, too –Why is the algorithm important? Constructive description of transformations

IBM Haifa Research Lab © 2007 IBM Corporation 11 Some Further Challenges Implementing the theoretical framework and algorithms Collecting empirical results Extending to real languages Apply sliding to more refactorings (e.g. Separate Query from Modifier [Fow], arbitrary method extraction) Apply the sliding-related refactorings in bigger reengineering challenges (e.g. Convert Procedural Design to Objects [Fow], componentization, conversion to SOA) Sliding beyond refactoring (e.g. in optimizing compilers, code obfuscation)

IBM Haifa Research Lab © 2007 IBM Corporation 12 Thanks! Acknowledgements –My DPhil [Ett] supervisor Oege de Moor And Mike Spivey, supervising during Oeges Sabbatical (2003) –Past and present members of the Programming Tools Group at Oxford, in particular Iván Sanabria, Yorck Hünke, Stephen Drape, Mathieu Verbaere, Damien Sereni –My thesis examiners Mark Harman and Jeremy Gibbons –Yishai Feldman and the SAM group

IBM Haifa Research Lab © 2007 IBM Corporation 13 References [CACM82] Programmers use slices when debugging, M. Weiser, 1982 [Back] A calculus of refinements for program derivations, 1988 [Dijkstra and Scholten] Predicate calculus and program semantics, 1990 [Morgan] Programming from specifications (2nd ed.), 1994 [IST98] Restructuring programs by tucking statements into functions, A. Lakhotia and J.-C. Deprez, 1998 [FOW] Refactoring: Improving the Design of Existing Code, M. Fowler, 2000 [POPL00] Semantics-preserving procedure extraction, R. Komondoor and S. Horwitz, 2000 [SSR01] Automated method-extraction refactoring by using block-based slicing, K. Maruyama, 2001 [IWPC03] Effective automatic procedure extraction, R. Komondoor and S. Horwitz, 2003 [AOSD04] Untangling: a slice extraction refactoring, R. Ettinger and M. Verbaere, 2004 [Ett] Refactoring via Program Slicing and Sliding, DPhil thesis, 2006 –Submitted version Successfully defended on 18 January 2007, with minor corrections –Revised version Corrections need to be approved…

IBM Haifa Research Lab © 2007 IBM Corporation 14 Backup

IBM Haifa Research Lab © 2007 IBM Corporation 15 int prod=1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The sum is " + sum); System.out.println("The product is " + prod); int sum=0; for (int i=0; i<a.length; i++) { sum += a[i]; } On Sliding and Code-Motion Transformations

IBM Haifa Research Lab © 2007 IBM Corporation 16 int sum=computeSum(a); int prod=1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The sum is " + sum); System.out.println("The product is " + prod); On Sliding and Code-Motion Transformations int computeSum(int[] a) { int sum=0; for (int i=0; i<a.length; i++) { sum += a[i]; } return sum; }

IBM Haifa Research Lab © 2007 IBM Corporation 17 int prod=1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The sum is " + computeSum(a)); System.out.println("The product is " + prod); int computeSum(int[] a) { int sum=0; for (int i=0; i<a.length; i++) { sum += a[i]; } return sum; } On Sliding and Code-Motion Transformations

IBM Haifa Research Lab © 2007 IBM Corporation 18 A Slicing Example Original programSlice for variable nl * Slicer developed by Mathieu Verbaere * Support a small subset of Java

IBM Haifa Research Lab © 2007 IBM Corporation 19 Extract Slice: The Extracted Method

IBM Haifa Research Lab © 2007 IBM Corporation 20 Extract Slice: The Complement redundant fragmentsin is not modified

IBM Haifa Research Lab © 2007 IBM Corporation 21 Extract Slice as a Method (rejection) Refactoring rejected: Input statements in extracted code (internal state of in is modified)

IBM Haifa Research Lab © 2007 IBM Corporation 22 Example: Fowlers video-store

IBM Haifa Research Lab © 2007 IBM Corporation 23

IBM Haifa Research Lab © 2007 IBM Corporation 24

IBM Haifa Research Lab © 2007 IBM Corporation 25

IBM Haifa Research Lab © 2007 IBM Corporation 26