A Survey of Software Refactoring Tom Mens, Tom Tourwé

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

Alternate Software Development Methodologies
Code Smell Research: History and Future Directions Second PLOW Installment - March 5, Nikolaos Tsantalis Computer Science & Software Engineering.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor Formal Methods in Software Engineering1.
Basic Concepts in Component-Based Software Engineering
Object-Oriented Analysis and Design
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
UML CASE Tool. ABSTRACT Domain analysis enables identifying families of applications and capturing their terminology in order to assist and guide system.
Object-Oriented Theories for Model Driven Architecture Tony Clark, King’s College, UK. Andy Evans, University of York, UK. Robert France, Colorado University,
Automatically Extracting and Verifying Design Patterns in Java Code James Norris Ruchika Agrawal Computer Science Department Stanford University {jcn,
Creating Architectural Descriptions. Outline Standardizing architectural descriptions: The IEEE has published, “Recommended Practice for Architectural.
© Copyright Eliyahu Brutman Programming Techniques Course.
SwE 313 Introduction to Rational Unified Process (RUP)
Describing Syntax and Semantics
1 Scenario-based Analysis of UML Design Class Models Lijun Yu October 4th, 2010 Oslo, Norway.
Mining Metamodels From Instance Models: The MARS System Faizan Javed Department of Computer & Information Sciences, University of Alabama at Birmingham.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
UML and Object Oriented Concepts
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Spectra Software Defined Radio Products Applying Model Driven Design, Generative Programming, and Agile Software Techniques to the SDR Domain OOPSLA '05.
Software Engineering CS B Prof. George Heineman.
Ontology Development Kenneth Baclawski Northeastern University Harvard Medical School.
1 CS 456 Software Engineering. 2 Contents 3 Chapter 1: Introduction.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring.
Introduction to MDA (Model Driven Architecture) CYT.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Unified Modeling Language, Version 2.0
Software Design Deriving a solution which satisfies software requirements.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Composition of UML Described Refactoring Rules Presented by Chin-Yi Tsai.
Modeling Component-based Software Systems with UML 2.0 George T. Edwards Jaiganesh Balasubramanian Arvind S. Krishna Vanderbilt University Nashville, TN.
1 Advanced Software Architecture Muhammad Bilal Bashir PhD Scholar (Computer Science) Mohammad Ali Jinnah University.
Requirements Engineering Methods for Requirements Engineering Lecture-30.
Verification of behavioural elements of UML models using B Truong, Ninh-Thuan and Souquieres, Jeanine In Proceedings of the 2005 ACM Symposium on.
Rational Unified Process Fundamentals Module 7: Process for e-Business Development Rational Unified Process Fundamentals Module 7: Process for e-Business.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Chapter 5: Software Re-Engineering Omar Meqdadi SE 3860 Lecture 5 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
HNDIT23082 Lecture 06:Software Maintenance. Reasons for changes Errors in the existing system Changes in requirements Technological advances Legislation.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
1 Technical & Business Writing (ENG-715) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Object Oriented Analysis and Design 1 Chapter 9 From Design to Implementation  Implementation Model  Forward, Reverse, and Round-Trip Engineering  Mapping.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Object-Oriented Parsing and Transformation Kenneth Baclawski Northeastern University Scott A. DeLoach Air Force Institute of Technology Mieczyslaw Kokar.
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 Contractual Consistency Between BON Static and Dynamic Diagrams Ali Taleghani July 30, 2004.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Reuse Contracts A Historic Overview Dr. Tom Mens Programming Technology Lab Vrije Universiteit Brussel Course OOSE.RC EMOOSE
21/1/ Analysis - Model of real-world situation - What ? System Design - Overall architecture (sub-systems) Object Design - Refinement of Design.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
A UML-Based Pattern Specification Technique Presented by Chin-Yi Tsai IEEE TRANSACTION ON SOFTWARE ENGINEERING, VOL. 30, NO. 3, MARCH 2004 Robert B. France,
UML (Unified Modeling Language)
Chapter 5 – System Modeling Lecture 1 1Chapter 5 System modeling.
Component-Based Software Engineering Components and Interfaces Paul Krause and Sotiris Moschoyiannis.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Object-Oriented Software Engineering Using UML, Patterns, and Java,
Systems Analysis and Design With UML 2
Daniel Amyot and Jun Biao Yan
A Declarative Evolution Framework for Object-Oriented Design Patterns
Chapter 4 System Modeling.
Refactoring.
Presentation transcript:

A Survey of Software Refactoring Tom Mens, Tom Tourwé IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, VOL. XX, NO. Y, MONTH 2004 Presented by: Kishen Maloor

Overview Restructuring, refactoring and associated activities Behavior preservation – Assertions, Formalisms… Types of software artifacts Tool support Qualities of refactoring tools Process support Conclusion

Restructuring and refactoring Restructuring is a transformation from one form of presentation to another Refactoring is the object-oriented variant of restructuring The subjects external behavior is preserved Idea is to make existing code more extensible

Refactoring activities Identify where the software should be refactored Determine which refactoring(s) should be applied to the identified places Guarantee that the applied refactoring preserves behaviour Apply the refactoring Assess the effect of the refactoring on quality characteristics of the software Maintain the consistency between the refactored program code and other software artifacts

Behavior Preservation A refactoring is a parameterized behavior-preserving program transformation Approaches to behavior preservation may perform checks either statically or dynamically Input Original System 2 … 1+1 2-3 5+3 4*6 = Refactored System 2 … Source: spic.kaist.ac.kr/~selab/html/Study/Lab%20Seminar/A%20Survey%20of%20Software%20Refactoring.ppt

Behavior Preservation Static: - Preconditions, graph transformations, (access, update and call) preservations, type checking… Dynamic: - Take dynamic information into account - Checks more aspects of the program behavior - WSL comes along with a tool that preserves dynamic behavior of programs [Bennett, 1995]

Behavior Preservation Ideally, the behavior preservation of refactorings should be proven formally. But, proving semantic correctness is an undecidable problem [Gupta, 1996] Therefore, a more conservative, engineering approach is needed We could do rigorous testing of the code We could use Assertions and formalisms to check for behavior preservation

Assertions Identify a set of invariants in the program that preserve its behavior for refactorings Create a set of conditions which guarantee that these invariants hold Pre- and postconditions are therefore formulated and checked before and after refactorings are applied Are a lightweight and automatic means of verification

Example of use of assertions Before refactoring After refactoring Consider the refactoring: Add Class (new name, package, superclasses, subclasses) Source: https://www.iam.unibe.ch/scg/svn_repos/Talks/OORP/Store/Refactoring-Lecture.ppt

Example of use of assertions Preconditions no class or global variable exists with new name in the same scope subclasses are all subclasses of all superclasses Postconditions new class is added into the hierarchy with superclasses as superclasses and subclasses as subclasses new class has name new name subclasses inherit from new class and not anymore from superclasses Invariant: Classes A, B & F are defined before and after the refactoring

Problems with assertions Opdyke proposed a set of seven invariants to preserve behavior for refactorings [Opdyke, 1992] Ex: Distinct class, Type safe assignments, Compatible signatures in member function definition, Inherited member variables not defined, Distinct member names, Distinct class names etc. A more complex language may need more preconditions Opdyke’s invariants were observed to be insufficient for C++ [Tokuda, 2001]

Problems with assertions Static checking of preconditions can sometimes be very expensive Preconditions do not consider the size or structure of programs [Roberts, 1999] suggests a way to augment refactorings with postconditions

Formalisms Graph Transformations - Programs represented as graphs - Refactorings correspond to graph production rules - Application of refactorings correspond to a graph transformation - Assertions specified as application pre- and postconditions Provides formal support for refactoring

Formalisms [Mens, 2002] uses graph rewriting to show that certain kinds of program behavior are preserved using static analysis Graph transformations can be used to reason about dependence between refactorings Ex. Move method and Rename method Analysis of sequential dependencies between refactorings can be useful

Other useful techniques Program Slicing Formal concept analysis Software metrics Software visualization Dynamic program analysis

Types of software artifacts Program source code - Supported by a variety of programming paradigms (Imperative, OO, Functional, AOP) - Formal support (WSL) Non-OO languages are as such more difficult to restructure More complex the language, harder it is to automate the refactoring process

Types of software artifacts Refactoring of designs, a recent research trend Independent of the underlying programming language Refactoring of UML diagrams [Boger, 2002] Refactoring pre- and post-conditions can be expressed using OCL

Types of software artifacts Design patterns describe program structure at a higher level Refactorings are used to introduce new design pattern instances into software

Types of software artifacts Restructuring software architectures - based on graphical representation of the architecture [Philipps, 1997] - Behavior specified by casual relationship between two components is preserved Software requirements - [Russo, 1998] restructure natural language requirements

Tool support Semiautomatic approach ? ? ? Refactoring Move Method Add Class Op1 Op2 Opn ? ? Refactored System ? Refactoring operations Source: spic.kaist.ac.kr/~selab/html/Study/Lab%20Seminar/A%20Survey%20of%20Software%20Refactoring.ppt

Tool support In the semiautomatic approach, the developer: - Identifies the part of the software to be refactored and selects an appropriate refactoring to apply Application of the refactoring is automatic Fully automated refactoring has been demonstrated to be feasible [Moore, 1996]

Tool support Fully automatic approach: - Refactorings can be easily undone - Can make the code difficult to understand Semiautomatic approach: - For large software, needs lots of human interaction; time consuming! - More useful-most knowledge required to perform refactoring cannot be extracted from software

Qualities of refactoring tools Reliability - Is it possible to check if the provided refactorings are truly behavior preserving? Tools check preconditions before applying them and perform tests afterwards Tools provide an undo mechanism to make undesired changes undone Coverage specifies the number of refactoring activities supported by the tool

Qualities of refactoring tools Configurability - Modifying bad smell specifications - Changing the links between bad smells and refactorings [Leitao, 2002] specifies a pattern language to express refactorings [Munoz, 2003] provides configurable threshold values to specify conditions for a bad smell

Qualities of refactoring tools Scalability - Combine frequently used primitive refactorings into composite refactorings - Better capture intent of software change - Performance gain - Weaken behavior preservation requirements for primitive refactorings - Support for cascaded refactorings [Tourwe, 2003]

Qualities of refactoring tools Language Independence - Applicability to different languages - Provide hooks to add language specific behavior [Lammel, 2002] proposes generic program refactoring – a language parametric framework, can be used with Java, XML… [Mens, 2002] Meta-model based approach Use of an intermediate formal language [Bennett, 1995]

Process Support An important activity in the software development process Software Reengineering - To restructure legacy software to implement a new solution - To assist a MDA tool

Process Support Agile Software Development (XP) - Develops and refactor software in small iterations Framework-Based or Product Line Development

Conclusion Provided an overview of refactoring; spoke about the different refactoring activities, prevalent problems and open issues, tool support for refactoring Spoke about how refactoring fits into the software engineering process Cited several relevant publications