IBM Haifa Research Lab © 2008 IBM Corporation Automating Big Refactorings for Componentization and the Move to SOA IBM Programming Languages and Development.

Slides:



Advertisements
Similar presentations
IBM Haifa Research Lab © 2008 IBM Corporation Co-Slicing for Program Comprehension and Reuse March 2008 Ran Ettinger Software Asset Management Group In.
Advertisements

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.
IBM Haifa Research Lab © 2007 IBM Corporation Refactoring via Program Slicing and Sliding June 2007 Ran Ettinger Software Asset Management Group In HRL.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Fortran Jordan Martin Steven Devine. Background Developed by IBM in the 1950s Designed for use in scientific and engineering fields Originally written.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
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.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
Detailed Design Kenneth M. Anderson Lecture 21
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
Program Slicing for Refactoring Advanced SW Tools Seminar Jan 2005Yossi Peery.
Architectural Design Principles. Outline  Architectural level of design The design of the system in terms of components and connectors and their arrangements.
Describing Syntax and Semantics
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Introduction SWE 619. Why Is Building Good Software Hard? Large software systems enormously complex  Millions of “moving parts” People expect software.
Spectra Software Defined Radio Products Applying Model Driven Design, Generative Programming, and Agile Software Techniques to the SDR Domain OOPSLA '05.
Introduction to High-Level Language Programming
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Verification and Validation Yonsei University 2 nd Semester, 2014 Sanghyun Park.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Refactoring Cristescu Marilena. Definitions Loose Usage: Reorganize a program(or something) As a noun: a change made to the internal structure of some.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Computer Science 240 © Ken Rodham 2006 Principles of Software Design.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
Refactoring Improving the structure of existing code Refactoring1.
The Daikon system for dynamic detection of likely invariants MIT Computer Science and Artificial Intelligence Lab. 16 January 2007 Presented by Chervet.
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University Inoue Laboratory Eunjong Choi 1 Investigating Clone.
SWE 316: Software Design and Architecture Objectives Lecture # 20 Improving the existing design: Refactoring SWE 316: Software Design and Architecture.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
Refactoring1 Improving the structure of existing code.
Software Engineering CS3003 Lecture 4 Code bad smells and refactoring.
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.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Semantics In Text: Chapter 3.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
Logical and Functional Programming
Industrial Project (236504) Advanced programming tools for refactoring Java code in Eclipse Student: Alexander Libov Supervisor: Dr. Ran Ettinger, IBM.
1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Refactoring Advanced Software Engineering Dr Nuha El-Khalili.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Refactoring1 Improving the structure of existing code.
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
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.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
DevCOP: A Software Certificate Management System for Eclipse Mark Sherriff and Laurie Williams North Carolina State University ISSRE ’06 November 10, 2006.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Software Testing.
Code Optimization.
Software Testing.
Ran Ettinger, IBM Research – Haifa Beijing, China 16 June 2012
Improving the structure of existing code
Refactoring.
Presentation transcript:

IBM Haifa Research Lab © 2008 IBM Corporation Automating Big Refactorings for Componentization and the Move to SOA IBM Programming Languages and Development Environments Seminar 2008 Aharon Abadi, Ran Ettinger and Yishai Feldman Software Asset Management Group IBM Haifa Research Lab

© 2008 IBM Corporation 2 Background  What is Refactoring? –The process of gradually improving the design of an existing software system by performing source code transformations that improve its quality in such a way that it becomes easier to maintain the system and reuse parts of it, while preserving the behavior of the original system  For example: Extract Method void printOwing(double amount) { printBanner(); // print details print(“name:” + _name); print(“amount:” + amount); } void printOwing(double amount) { printBanner(); printDetails(amount); } void printDetails(double amount) { print(“name:” + _name); print(“amount:” + amount); } Source: Martin Fowler’s online refactoring catalog

IBM Haifa Research Lab © 2008 IBM Corporation 3 Prior Art  Refactoring to Design Patterns + 

IBM Haifa Research Lab © 2008 IBM Corporation 4 Our Interest: Big Refactorings  Enterprise Architecture Patterns

IBM Haifa Research Lab © 2008 IBM Corporation 5 The Gap: Techniques and Tools for Enterprise Refactoring ??

IBM Haifa Research Lab © 2008 IBM Corporation 6 Automating Big Refactorings Enterprise Refactorings Separate Presentation Code from Business Logic (introduce the MVC pattern), Extract Reusable Services (implementing SOA), etc. Small Refactorings Rename Paragraph, Split/Merge Paragraphs, Extract/Inline Paragraph/Section/Program, Extract Slice, Swap Consecutive (Independent) Statements/Sentences/Paragraphs/Sections, Split/Merge (Consecutive) Conditionals, Loop-Invariant Code Motion, etc. Composition Flexibility Allow (user-determined) choice between alternatives Reliability* Guarantee behavior preservation Applicability Avoid unnecessary rejections by precise identification of (weak) preconditions Deep Program Analysis Program analysis infrastructure for legacy enterprise software systems: A powerful static analysis infrastructure using the plan-calculus intermediate representation Enabling Technology Required Quality * See for examples of bugs in modern IDEshttp://progtools.comlab.ox.ac.uk/projects/refactoring/bugreports

IBM Haifa Research Lab © 2008 IBM Corporation 7 Example: Introduce the MVC Pattern

IBM Haifa Research Lab © 2008 IBM Corporation 8 As-Is Version: Photo Album Web Application Source: Alex Chaffee, draft “Refactoring to MVC” online article, 2002

IBM Haifa Research Lab © 2008 IBM Corporation 9 To-Be Version: Photo Album Web Application Source: Alex Chaffee, draft “Refactoring to MVC” online article, 2002 Controller View Model Presentation Model

IBM Haifa Research Lab © 2008 IBM Corporation 10 Small Refactorings on the move to MVC  All kinds of renaming –Variables, fields, methods, etc.  Extracting program entities –Constants, local (temp) variables, parameters, methods (Extract Method, Replace Temp with Query, Decompose Conditional), classes (Extract Class, Extract Superclass, Extract Method Object) –Some reverse refactorings too, to inline program entities  Moving program entities –Constants, fields, methods (Move Method, Pull-Up Method), statements (Swap Statements), classes  Replace Algorithm

IBM Haifa Research Lab © 2008 IBM Corporation 11 Shortcomings of Eclipse on the move to MVC  Missing implementation for key transformations –Extract Class, Extract Method Object  Buggy implementation of some refactorings –Extract/Inline Local Variable: Ignores potential modification of parameters (on any path from source to target location) –See for examples of bugs in (earlier releases of) modern IDEs  Restricted implementation of existing refactorings –Extract Method: contiguous code only; weak control over parameters –Move Method: Source class must have a field with type of target class –Extract Local Variable: No control over location of declaration

IBM Haifa Research Lab © 2008 IBM Corporation 12 Thanks!

IBM Haifa Research Lab © 2008 IBM Corporation 13 Backup

IBM Haifa Research Lab © 2008 IBM Corporation 14 Internal Representation: The Plan Calculus  Wide-spectrum –Specification to implementation  Canonical –Abstracts away from syntactic variations  Language independent –All legacy languages have similar capabilities  Expressive –Directly expresses program semantics in terms of data- flow and control-flow  Convenient for machine manipulation –Naturally expresses semantic transformations Rich, C A formal representation for plans in the programmer's apprentice. In Readings in Artificial intelligence and Software Engineering, C. Rich and R. C. Waters, Eds. Morgan Kaufmann Publishers, San Francisco, CA,

IBM Haifa Research Lab © 2008 IBM Corporation 15 MOVE 0 TO TOTAL-SALE MOVE 0 TO TOTAL-PAY PERFORM VARYING i FROM 1 BY 1 UNTIL i > DAYS ADD SALE(i) TO TOTAL-SALE COMPUTE TOTAL-PAY = TOTAL-PAY + 0.1*SALE(i) IF SALE(i)>1000 ADD 50 TO TOTAL-PAY END-IF END-PERFORM COMPUTE PAY = TOTAL-PAY / DAYS COMPUTE PROFIT = 0.9*TOTAL-SALE - COST MOVE 0 TO TOTAL-PAY PERFORM VARYING i FROM 1 BY 1 UNTIL i > DAYS COMPUTE TOTAL-PAY = TOTAL-PAY + 0.1*SALE(i) IF SALE(i)>1000 ADD 50 TO TOTAL-PAY END-IF END-PERFORM COMPUTE PAY = TOTAL-PAY / DAYS MOVE 0 TO TOTAL-SALE PERFORM VARYING i FROM 1 BY 1 UNTIL i > DAYS ADD SALE(i) TO TOTAL-SALE END-PERFORM COMPUTE PROFIT = 0.9*TOTAL-SALE - COST MOVE 0 TO TOTAL-SALE MOVE 0 TO TOTAL-PAY PERFORM VARYING i FROM 1 BY 1 UNTIL i > DAYS ADD SALE(i) TO TOTAL-SALE COMPUTE TOTAL-PAY = TOTAL-PAY + 0.1*SALE(i) IF SALE(i)>1000 ADD 50 TO TOTAL-PAY END-IF END-PERFORM COMPUTE PAY = TOTAL-PAY / DAYS COMPUTE PROFIT = 0.9*TOTAL-SALE - COST Program Sliding  A family of provably-correct code-motion untangling transformations –Automate slice extraction: Sequential composition of a selected slice with its complement (i.e. co-slice); Useful for refactoring, componentization, the move to SOA, obfuscation, etc. –Combine statement reordering with code duplication, including duplication of assignments –Benefit from the best of leading earlier solutions without suffering some of their respective deficiencies  Sliding is particularly strong in –Preserving behavior –Maximizing reuse (of extracted computation’s results, in the complement) –Minimizing code duplication, i.e. yielding a smaller, more desirable complement; –Improving applicability, i.e. less reasons to reject a request Example source: Lakhotia and Deprez (rewritten in COBOL)

IBM Haifa Research Lab © 2008 IBM Corporation 16 Towards a COBOL Refactoring Catalog  Rename Paragraph –This refactoring might look trivial, but as it is with the renaming of variables, it must be done with care: the new name must be valid, it must not conflict with existing names, and it must be replaced correctly in each call (PERFORM, GO TO, etc.), without violating any column restrictions  Split/Merge Paragraphs –When merging two consecutive paragraphs, one must check the second is not referenced, or if it is, its reference must always follow a call to the first paragraph such that the two calls can be merged. Similarly, one must verify that any call to the first paragraph is either followed by a call to the second, or it must be a non-returning call that implies fall-through to the second paragraph  Extract/Inline Paragraph/Section/Program –Could support clone detection too, such that upon extraction, the tool will identify (at least exact) clones of the selected code, and suggest to replace it too with a call to the newly introduced program  Extract Slice (through Sliding) –First support the extraction of the code for computing a set of variables in a selected compound statement (or sentence); later add support for extraction from internal program points, i.e., the slicing criteria involves pairs of program point and (sets of) variables of interest (at that particular point); and finally support arbitrary method extraction, i.e., the slicing criteria involves a set of statements (or sentences), not necessarily contiguous, for extraction  Swap Consecutive (Independent) Executable Program Entities –Such as compound statements, sentences, and even paragraphs or sections  Split/Merge (Consecutive) Conditionals –So long as two instances of the conditional’s predicate are guaranteed to evaluate similarly  Loop-Invariant Code Motion –Computation flavor: A loop-invariant computation is moved inside/outside that loop, as in optimizing compilers –Conditional flavor: Instead of a computation, it is a loop-invariant conditional being moved If moved out, the loop itself is duplicated, for each branch of the conditional, but with each branch simplified based on the known conditional’s result