Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM.

Slides:



Advertisements
Similar presentations
IBM Haifa Research Lab © 2007 IBM Corporation Program Sliding A Novel Approach for the Automation of Slicing-Based Refactoring June 2007 Ran Ettinger In.
Advertisements

IBM Haifa Research Lab © 2007 IBM Corporation Refactoring via Program Slicing and Sliding June 2007 Ran Ettinger Software Asset Management Group In HRL.
User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation For C# Developers.
Heuristic Search techniques
Symmetry-Aware Predicate Abstraction for Shared-Variable Concurrent Programs Alastair Donaldson, Alexander Kaiser, Daniel Kroening, and Thomas Wahl Computer.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
REFACTORING Improving the Design of Existing Code Atakan Şimşek e
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
1. 2 FUNCTION INLINE FUNCTION DIFFERENCE BETWEEN FUNCTION AND INLINE FUNCTION CONCLUSION 3.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
2  Problem Definition  Project Purpose – Building Obfuscator  Obfuscation Quality  Obfuscation Using Opaque Predicates  Future Planning.
Workflow API and workflow services A case study of biodiversity analysis using Windows Workflow Foundation Boris Milašinović Faculty of Electrical Engineering.
Introduction SWE 619. Why Is Building Good Software Hard? Large software systems enormously complex  Millions of “moving parts” People expect software.
Students: Nadia Goshmir, Yulia Koretsky Supervisor: Shai Rozenrauch Industrial Project Advanced Tool for Automatic Testing Final Presentation.
Object Oriented Software Development
A Survey of Software Refactoring Tom Mens, Tom Tourwé
1 Web Based Programming Section 6 James King 12 August 2003.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
JUnit in Action SECOND EDITION PETAR TAHCHIEV FELIPE LEME VINCENT MASSOL GARY GREGORY ©2011 by Manning Publications Co. All rights reserved. Slides Prepared.
Advanced Programing practices
Students: Nidal Hurani, Ghassan Ibrahim Supervisor: Shai Rozenrauch Industrial Project (234313) Tube Lifetime Predictive Algorithm COMPUTER SCIENCE DEPARTMENT.
IBM Haifa Research Lab © 2008 IBM Corporation Automating Big Refactorings for Componentization and the Move to SOA IBM Programming Languages and Development.
University of Toronto Department of Computer Science CSC444 Lec05- 1 Lecture 5: Decomposition and Abstraction Decomposition When to decompose Identifying.
Software Refactoring Part I: Introduction Bartosz Walter Advanced Object-Oriented Design Lecture 5.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
17-Oct-15 Refactoring. 2 Refactoring is: restructuring (rearranging) code......in a series of small, semantics-preserving transformations (i.e. the code.
CSE 219 Computer Science III Program Design Principles.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Refactoring1 Refactoring DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY February 6, 2009.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Final Presentation Industrial project Automatic tagging tool for Hebrew Wiki pages Supervisors: Dr. Miri Rabinovitz, Supervisors: Dr. Miri Rabinovitz,
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
CASE/Re-factoring and program slicing
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
1 Structure of a C Program (continued) Presentation original from Dr. Turner’s class USF - COP C for Engineers Summer 2008.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
11 Debugging Programs Session Session Overview  Create and test a method to calculate percentages  Discover how to use Microsoft Visual Studio.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Session 7 Introduction to Inheritance. Accumulator Example a simple calculator app classes needed: –AdderApp - contains main –AddingFrame - GUI –CloseableFrame.
Refactoring. DCS – SWC 2 Refactoring ”A change made to the internal structure of software to make it easier to understand and cheaper to modify without.
CS223: Software Engineering Lecture 18: The XP. Recap Introduction to Agile Methodology Customer centric approach Issues of Agile methodology Where to.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
CSCE 240 – Intro to Software Engineering Lecture 3.
Software Design and Development Development Methodoligies Computing Science.
High-level language programming paradigms. Programming languages come in many forms or 'paradigms'. Each form of language offers advantages over other.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
CS223: Software Engineering
Software Testing.
User-Written Functions
Module Road Map Refactoring Why Refactoring? Examples
Names and Attributes Names are a key programming language feature
C++ Plus Data Structures
Ran Ettinger, IBM Research – Haifa Beijing, China 16 June 2012
Design by Contract Fall 2016 Version.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Program Slicing Baishakhi Ray University of Virginia
Overview of Eclipse Lectures
MATERI PL/SQL Procedures Functions Packages Database Triggers
Refactoring.
Chapter 4: Writing and Designing a Complete Program
Improving the Performance of Functions
Presentation transcript:

Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM. COMPUTER SCIENCE DEPARTMENT Technion - Israel Institute of Technology August 12, 2009

Our goal  Improving code maintenance by enabling advanced refactoring methods (in Eclipse).  Implement Replace Temp with Query refactoring  Why is it important?  The benefit is increased readability (in the refactored version) and reusability (of the extracted computation)  The steps of turning procedural design to objects mainly involve introducing new classes, extracting methods, moving variables and methods (to the new classes), inlining methods and renaming variables and methods. All those are either straightforward or already supported by modern refactoring tools. It is the extraction of non-contiguous code (as in Replace Temp with Query) for which automation is missing and required.

Definitions  Sliced Variable – the variable that serves as a base to compute a slice  Selected by the user.  It is important which of the occurrences is selected.  Slice – a piece of code that eventually calculates the sliced variable value in the location selected by the user  The slice does not include the statement which holds the sliced variable.  The relevant code starts at the head of the current block and ends immediately before the selected statement.  Co-Slice - a piece of code that calculates the rest of the calculations done inside the block apart from the sliced variable  Can contain statements from the slice.  Also located between the head of the current block and the selected statement.  Sliding – separating the slice from the co-slice in the covering block.  Must preserve the observable behavior of the program.

Methodology part I User chooses a variable reference The main workflow of the actions is as described below: Use WALA to calculate the Slice Replace temp with query Show Slice Use WALA to calculate the Co-Slice

Methodology part II Duplicate the covering block’s code The Replace Temp with Query in a bit more detail: Leave only the slice in the first part and co-slice and rest of the code in the second part Run extract method on the slice Run inline temp on the declaration of the sliced variable Slice Co-Slice Check preconditions a return statement for the extracted variable will be added at the end of the extracted method, in the original block, the slice will be replaced by a declaration of that temp with a call to the extracted method for its initialization.

Replace Temp with Query Example...{ int sum = 0; int prod = 1; for (int i=0; i<a.length; i++) { sum += a[i]; prod *= a[i]; } System.out.println("The total sum is " + sum); System.out.println("The product is " + prod);... }... The user chose sum to be the sliced variable (that is, the temp to be replaced with a query)

Replace Temp with Query Example – Sliding …{ int sum = 0; for (int i=0; i<a.length; i++) { sum += a[i]; } int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + sum); System.out.println("The product is " + prod); } … The Slice – Extract Method fragment The Co-Slice

Replace Temp with Query Example –– After Extract Method int computeSum(int[] a) { int sum = 0; for (int i=0; i<a.length; i++) { sum += a[i]; } return sum; }... { int sum = computeSum(a); int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + sum); System.out.println("The product is " + prod);... }... The extracted method Inline Temp selection

Replace Temp with Query Example –– After Inline Temp... { int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + computeSum(a)); System.out.println("The product is " + prod);... }... The sum variable is replaced with a computeSum query Int computeSum(int[] a) { int sum = 0; for (int i=0; i<a.length; i++) { sum += a[i]; } return sum; }

Replace Temp with Query Example - Recap... { int sum = 0; int prod = 1; for (int i=0; i<a.length; i++) { sum += a[i]; prod *= a[i]; } System.out.println("The total sum is " + sum); System.out.println("The product is " + prod);... }... …{ int sum = 0; for (int i=0; i<a.length; i++) { sum += a[i]; } int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + sum); 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; }... { int sum = computeSum(a); int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + sum); System.out.println("The product is " + prod);... } { int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } System.out.println("The total sum is " + computeSum(a)); System.out.println("The product is " + prod);... }...

Replace Temp with Query Example – Final result Int computeSum(int[] a) { int sum = 0; for (int i=0; i<a.length; i++) { sum += a[i]; } return sum; }... { System.out.println("The total sum is " + computeSum(a)); System.out.println("The product is " + computeProd(a));... }... Int computeProd(int[] a) { int prod = 1; for (int i=0; i<a.length; i++) { prod *= a[i]; } return prod; }

Achievements  A fully working “Show Slice” action  Generates breakpoints on the slice’s lines.  Shows pop-up with more detail about the slice.  Works on entire compilation unit (not method only).  A rudimentary “Replace temp With Query” refactoring  Works on simple examples.  more work is needed on identifying and implementing preconditions to guarantee behavior preservation.  Calculates slice and co-slice only in the covering block (as it should).  Runs existing refactoring tools – “Extract Method” and “Inline Temp”.

Limitations  WALA limitations  Variable declarations are not part of the slice.  Conditional branches are part of the slice when they have nested statements that are not part of the block.  Works slowly ( to WALA's defense slicing is known to be complex, it actually analyses the whole program, not only the selected method).  Works only on methods that are reachable from the main method.  Replace Temp with Query limitations  Needs better pre-condition checking and extension to more use cases.  An import must be updated on the move from one Eclipse version to another.  Need to handle variable declarations better.  Function calls handled wrong by the slicer (probably because of the default use of the pointer analysis).  A very basic sliding algorithm is implemented -- in the spirit of the older Tucking, a transformation due to Lakhotia and Deprez.

Conclusions  It is hard to work in a team (even of two) without source control  Working with large scale software is difficult  One can easily be lost inside the code.  Hard to tell what the flow is.  The refactoring framework in Eclipse/JDT is not easily ready for composition of refactoring tools  Code analysis is an interesting and complicated subject that doesn’t get enough coverage during undergraduate studies  Industrial Project course offers a real-life experience of how software development occurs  Needed experience for all software engineering students.  It can contribute to better blending of the student in the industry afterwards.