Demo of Software Refactoring with Eclipse Giriprasad Sridhara CISC 879 Spring 2007 May 15 2007.

Slides:



Advertisements
Similar presentations
Copyright © IBM Corp., Introducing the new Web Tools JavaScript™ Features Phil Berkland IBM Software Group 9/26/2007.
Advertisements

Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 7 1 Microsoft Office Excel 2003 Tutorial 7 – Working With Excel’s Editing.
Modern app development Continuous value delivery and rapid response to change.
Software Restructuring(Refactoring) Giriprasad Sridhara CISC 879 Spring 2007 May
Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
20-Jun-15 Eclipse. Most slides from: 2 About IDEs An IDE is an Integrated Development Environment.
13-Jul-15 Refactoring II. Books Design Patterns is the classic book by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides Basically a catalog.
Stimulating reuse with an automated active code search tool Júlio Lins – André Santos (Advisor) –
Source Control Repositories for Enabling Team Working Svetlin Nakov Telerik Corporation
Software Development Unit 6.
(code name: Data Dude) Josh Robinson Aculix.
Test Automation Best Practices
Test-Driven Development With Visual Studio 2005 Erno de Weerd Info Support.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
A First Program Using C#
Chapter 1 Introduction to Visual Basic Programming and Applications 1 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta.
Chapter 1 Introduction to Visual Basic Programming and Applications 1 Joshi R.G. Dept. of Computer Sci. YMA.
WorkPlace Pro Utilities.
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.
Miscellaneous Excel Combining Excel and Access. – Importing, exporting and linking Parsing and manipulating data. 1.
Software Refactoring Part I: Introduction Bartosz Walter Advanced Object-Oriented Design Lecture 5.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
Version control Using Git Version control, using Git1.
Reviewing Recent ICSE Proceedings For:.  Defining and Continuous Checking of Structural Program Dependencies  Automatic Inference of Structural Changes.
TOOLS FOR DESIGN AND DEVELOPMENT ENVIRONMENTS. Case study - ECLIPSE Lecture notes 7.
SWEN 302: AGILE METHODS Roma Klapaukh & Alex Potanin.
Hipikat: A Project Memory for Software Development The CISC 864 Analysis By Lionel Marks.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Refactoring Improving the structure of existing code Refactoring1.
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Chapter 17 Creating a Database.
Productivity Tools Ken Nguyen Department of Information Technology Clayton State University.
P.R. James © P.Chalin et al.1 An Integrated Verification Environment for JML: Architecture and Early Results Patrice Chalin, Perry R. James, and George.
Refactoring1 Improving the structure of existing code.
Refactoring and Synchronization with the StarTeam Plug-in for Eclipse  Jim Wogulis  Principal Architect, Borland Software Corporation.
Eclipse 24-Apr-17.
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. Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
1 Working with ASP.NET Master Pages By huda AlSuwailem Reference: Mastering Microsoft Visual Web Developer 2005 Express Edition by John Paul Mueller.
Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM.
Refactoring - 1 CS494: Intro. to Refactoring Readings: –Refactoring for everyone: How and why to use Eclipse's automated refactoring features. By David.
An Introduction to Forms. The Major Steps of a MicroSoft Access Database  Tables  Queries  Forms  Macros  Reports  Modules On our road map, we are.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
® IBM Software Group © 2007 IBM Corporation Module 1: Getting Started with Rational Software Architect Essentials of Modeling with IBM Rational Software.
Cross Language Clone Analysis Team 2 February 3, 2011.
Refactoring1 Improving the structure of existing code.
Recommending Adaptive Changes for Framework Evolution Barthélémy Dagenais and Martin P. Robillard ICSE08 Dec 4 th, 2008 Presented by EJ Park.
TEAM FOUNDATION VERSION CONTROL AN OVERVIEW AND WALKTHROUGH By: Michael Mallar.
Eclipse 27-Apr-17.
Data Mining What is to be done before we get to Data Mining?
 Project Team: Suzana Vaserman David Fleish Moran Zafir Tzvika Stein  Academic adviser: Dr. Mayer Goldberg  Technical adviser: Mr. Guy Wiener.
Java IDE Dwight Deugo Nesa Matic
Refactoring Tools – Proparse, Prorefactor, Prolint etc. Steven Lichtenberg Sr. Technologist Jenark Business Systems, Inc.
1 New Perspectives on Access 2016 Module 8: Sharing, Integrating, and Analyzing Data.
Principles and examples
Module Road Map Refactoring Why Refactoring? Examples
Eclipse 20-Sep-18.
Overview of Eclipse Lectures
: Clone Refactoring Davood Mazinanian Nikolaos Tsantalis Raphael Stein
Improving the structure of existing code
Microsoft Office Excel 2003
Git started with git: 2018 edition
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Java Code Review with CheckStyle
Refactoring.
Presentation transcript:

Demo of Software Refactoring with Eclipse Giriprasad Sridhara CISC 879 Spring 2007 May

Road Map Demo with Eclipse Demo with Visual Studio (if time permits) Eclipse plug-in to –Do your own refactoring (if time permits) Examples of refactorings –In real world code Apache Struts Free open-source framework –for creating Java web applications

Road Map Eclipse vs IDEA - Comparison –NOT an IDE comparison! –BUT a Comparison of the refactoring support –Like, Eclipse supports Refactoring A, but not IDEA –Refactoring B has a bug in Eclipse but not in IDEA –So on…

Refactoring tool Why have a refactoring tool (?) Is a refactoring tool redundant –If we have good unit test suite (?) –i.e. We can easily check behaviour preservation –NO! Refactoring by hand –Tedious –Error Prone –Time consuming Without a tool –Developers may NOT refactor!

Job done by refactoring tool Extract Method Refactoring (manual versus by tool) –Remember Extract Method ? A tool does the following: –Checks the selected code is legal to extract –Computes number of parameters to the method –Computes the required return value and type from the method –Allows to specify Name of the method Order of parameter passing –Extracts the code into the new method –Creates the new method in the original class. Compare with doing manually –Show In Eclipse (group2.ExtractMethod_etal::CnvrtTemp)

Technical Requirements for a Refactoring Tool Program database –A searchable repository –For example, For Rename Method, what do we need? We need to find all calls to the method –Lexical searches (grep) Won’t work! Can’t distiniguish between –a name like “temperature” which can be »A method »A variable »In the program comments

Technical Requirements of a Refactoring tool Parse Trees (AST) –Refactorings use this –Manipulate this –For Rename Method Rewrite the AST –Change the MethodDeclaration node name –Change all the MethodInvocation node names which referred to the old name Accuracy –The refactored code should be accurate –i.e. preserve behaviour

Practical Requirements for a Refactoring Tool Speed –If the refactoring tool is slow (?) –Developer may not refactor at all! –OR may do it by hand with all its associated problems Undo a refactoring –Without this (?) –We have to use an old version to revert Available within the IDE

Eclipse Refactoring support Mainly Java support via the JDT Very poor support for C++ from the CDT –Only Rename refactoring! –This is supposed to improve –With the new CDT 4.0 release. The Java refactoring –Available from Main menu –Context (right-click) menu –Undo/redo refactoring Merged with Edit->Undo/Redo Menu This is bad! Why? We have to navigate past edit actions performed after a refactoring

Eclipse Refactorings General work flow Choose a refactoring from main/context menu If not applicable –For right click it is disabled –For main menu A dialog saying not applicable shows up Informs what has to be selected for applicability Example, For Rename refactoring Must select Method, Variable, Class Show in eclipse

Eclipse Refactorings If applicable –Additional dialog for parameters –For Rename method, –Ask for new method name Show preview of the refactored code –Shows potential problems –For Rename Method (?) –If there is a name conflict A method with the new name and same signature exists in the hierarchy, already Once user accepts the changes, –do the changes.

Eclipse Refactorings If there were problems shown in the preview –BUT, the user ignored them (?) –The refactored code will also have the same problems –i.e. it will not compile.

Eclipse Refactoring Menu Organization Divided into 7 groups Group 1 –Name and physical organization –Rename and Move Group 2 –Methods –Extract Method, Change Signature, Inline, Extract Constant, Extract Local variable.

Eclipse Refactoring Menu Organization Group 3 –Within class –Nested, anonymous classes. Group 4 –Inheritance hierarchy –Pull up, Push down Group 5 –Miscellaneous –Indirection, Factory

Eclipse Refactoring Menu Organization Group 6 –Generics Group 7 –Scripts and Refactoring History –History Shows –Date and time of refactorings –The actual refactorings Method Cnvrt was renamed to Convert Additional choices made by the developer –Like, Update the name even in program comments.

Eclipse Refactoring Menu Organization Record refactorings (Create Script) Playback refactorings (Apply Script) Where would this be helpful (?) –Library developer can do refactorings of APIs –Create script of these refactorings. –He can then distribute it to Library users –Library user can avoid manual updates to sync with the library API change –But playback the refactorings from the script

Microsoft Visual Studio refactorings No direct support in.Net 2003 version –Believe there is support in VS 2005, –But I don’t have access to it. –90 day trial version available. So used an external trial product –Resharper (JetBrains) –Same company that produced IntelliJ IDEA Resharper –Add on to Visual Studio –Similar support like Eclipse (Main and context menu) –Supports only C# langauge

Eclipse plug-in to do your own refactoring ibm.com/developerworks/opensource/ library/os-ecjdt/

Real world refactorings Struts –Examples of Refactorings –Between version 1.1 and 1.2 Rename Method Pull Up Method Change Method Signature Move Method –Detection mechanism Refactoring Crawler (Dig et al UIUC)

Eclipse vs Intellij IDEA A quick comparison of the refactoring support offered by –Eclipse –IntelliJ IDEA Basic Facts –Eclipse Open source (IBM) Customizable to different languages like Java, C++ –IntelliJ IDEA Commercial (JetBrains ) Java IDE

Eclipse vs Intellij IDEA IntelliJ IDEA Pricing –Commercial - $499 –Personal - $249 –Academic - $99 –Classroom – Free! –Open Source – Free!

Eclipse vs Intellij IDEA IDEA does not appear to have –Ability to create and apply refactoring scripts –Does not show history of refactorings clearly –It has “migrate” refactorings But this is for packages and classes Also the procedure described appears very tedious between-api

Eclipse vs Intellij IDEA IDEA’s Rename Method refactoring is smarter! –Renames Method even in Java Reflection API call –i.e. –Class::getMethod(“oldName”…) –will be replaced with –Class::getMethod(“newName”…)

Eclipse vs Intellij IDEA Eclipse’s generify refactoring is better –In my example, group6.InferGenericTypeArg –It inferred generic type for List and Iterator – IDEA did only for Iterator –This is bad! The List is the type that must be type safe Introduce Parameter –Eclipse has a bug!! –IDEA does not have it!

Eclipse vs Intellij IDEA IDEA supports an important refactoring –Replace Inheritance with delegation –This refactoring allows to remedy Violations of the Liskov Substitution Principle –Eclipse does not support this. IDEA supports –Replace Temp With Query –Eclipse does not.

Eclipse vs Intellij IDEA Extract Method – Duplicated Code –Suppose we do Extract Method –And the same piece of code is Duplicated at other places –IDEA detects this Replaces the clones as well, With the extracted method call! –Officially, Eclipse is supposed to recognize this and handle it, but it does not work always!

Eclipse vs Intellij IDEA IDEA supports Invert Boolean refactoring –Eclipse does not –But this is a minor refactoring Preview of refactored code –IDEA and Eclipse show preview –But Eclipse’s preview is better –It shows both the current code and new refactored code juxtaposed for comparison –IDEA does not present such a preview So it is hard to visualize the changes. For many refactorings like ExtractMethod IDEA does not present previews at all.

Sources of the presentation Refactoring – Martin Fowler Wikipedia Eclipse online documentation IBM Eclipse

Questions? Thank you.