OORPT Object-Oriented Reengineering Patterns and Techniques 4. Reverse Engineering Prof. O. Nierstrasz.

Slides:



Advertisements
Similar presentations
© S. Demeyer, S. Ducasse, O. Nierstrasz Migration Testing and Migration What and Why  Reengineering Life-Cycle Tests: Your Life Insurance !  Grow.
Advertisements

Software Modeling SWE5441 Lecture 3 Eng. Mohammed Timraz
ESE Einführung in Software Engineering 6. Modeling Objects and Classes Prof. O. Nierstrasz.
1 Object-Oriented Reengineering © S. Demeyer, S.Ducasse, O. Nierstrasz Lecture 2 Radu Marinescu Reverse Engineering.
© S. Demeyer, S. Ducasse, O. Nierstrasz Reverse Engineering.1 4. Reverse Engineering JEdit Experience What and Why Setting Direction  Most Valuable First.
ESE Einführung in Software Engineering 7. Modeling Behaviour Prof. O. Nierstrasz.
Using UML, Patterns, and Java Object-Oriented Software Engineering Royce’s Methodology Chapter 16, Royce’ Methodology.
OORPT Object-Oriented Reengineering Patterns and Techniques 7. Problem Detection Prof. O. Nierstrasz.
© S. Demeyer, S. Ducasse, O. Nierstrasz Reverse Engineering.1 2. Reverse Engineering What and Why Setting Direction  Most Valuable First First Contact.
Introduction to Software Engineering 13. Software Evolution.
Introduction To System Analysis and Design
Object-Oriented Reengineering Patterns and Techniques Prof. O. Nierstrasz Prof. S. Ducasse T.
ESE Einführung in Software Engineering N. XXX Prof. O. Nierstrasz Fall Semester 2009.
The Software Composition Group Prof. O. Nierstrasz
Object-Oriented Reengineering Oscar Nierstrasz Software Composition Group University of Bern.
© S. Demeyer, S. Ducasse, O. Nierstrasz Intro.1 1. Introduction Goals Why Reengineering ?  Lehman's Laws  Object-Oriented Legacy Typical Problems  common.
OORPT Object-Oriented Reengineering Patterns and Techniques 1. Introduction Prof. O. Nierstrasz.
13. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Summary, Trends, Research...  Summary: functional, logic and object-oriented.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
© S. Demeyer, S. Ducasse, O. Nierstrasz Reverse Engineering.1 3. Reverse Engineering What and Why Setting Direction  Most Valuable First First Contact.
Metamodeling Seminar X. CHAPTER Prof. O. Nierstrasz Spring Semester 2008.
ESE Einführung in Software Engineering X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
N. XXX Prof. O. Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes.
© S. Demeyer, S. Ducasse, O. Nierstrasz Migration.1 5. Testing and Migration What and Why  Reengineering Life-Cycle Tests: Your Life Insurance !  Grow.
OORPT Object-Oriented Reengineering Patterns and Techniques 10. Testing and Migration Prof. O. Nierstrasz.
CS350/550 Software Engineering Lecture 1. Class Work The main part of the class is a practical software engineering project, in teams of 3-5 people There.
12. Summary, Trends, Research. © O. Nierstrasz PS — Summary, Trends, Research Roadmap  Summary: —Trends in programming paradigms  Research:...
Object-Oriented Reengineering Patterns and Techniques Prof. O. Nierstrasz Prof. S. Ducasse T.
© S. Demeyer, S. Ducasse, O. Nierstrasz Chapter.1 MakeMoney Corp. C*O of MakeMoney Corp. Our Vision  We invest in software  We do not know software 
OORPT Object-Oriented Reengineering Patterns and Techniques X. CHAPTER Prof. O. Nierstrasz.
CP — Concurrent Programming X. CHAPTER Prof. O. Nierstrasz Wintersemester 2005 / 2006.
Software Architecture Quality. Outline Importance of assessing software architecture Better predict the quality of the system to be built How to improve.
12. eToys. © O. Nierstrasz PS — eToys 12.2 Denotational Semantics Overview:  … References:  …
Mastering OOA/OOD with UML. Contents Introduction Requirements Overview OOAOOD.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Release & Deployment ITIL Version 3
Introduction to RUP Spring Sharif Univ. of Tech.2 Outlines What is RUP? RUP Phases –Inception –Elaboration –Construction –Transition.
1 Shawlands Academy Higher Computing Software Development Unit.
IT Systems Analysis & Design
Karolina Muszyńska. Reverse engineering - looking at the solution to figure out how it works Reverse engineering - breaking something down in order to.
Demystifying the Business Analysis Body of Knowledge Central Iowa IIBA Chapter December 7, 2005.
Business Analysis and Essential Competencies
Team Skill 6: Building the Right System From Use Cases to Implementation (25)
© S. Demeyer, S. Ducasse, O. Nierstrasz Intro.1 1. Introduction Goals Why Reengineering ?  Lehman's Laws  Object-Oriented Legacy Typical Problems  common.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
1 Chapter 5 Software Engineering Practice. 2 What is “Practice”? Practice is a broad array of concepts, principles, methods, and tools that you must consider.
Introduction To System Analysis and Design
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Coming up: Software Engineering: A Practitioner’s Approach, 6/e Chapter 5 Practice: A Generic View copyright © 1996, 2001, 2005 R.S. Pressman & Associates,
Systems Design Approaches The Waterfall vs. Iterative Methodologies.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
University of Southern California Center for Systems and Software Engineering Model-Based Software Engineering Supannika Koolmanojwong Spring 2013.
Lecture 7: Requirements Engineering
Summarizing the Content of Large Traces to Facilitate the Understanding of the Behaviour of a Software System Abdelwahab Hamou-Lhadj Timothy Lethbridge.
IS2210: Systems Analysis and Systems Design and Change Twitter:
Object-Oriented Reengineering Patterns 1. Introduction.
The Software Development Process
1 Object-Oriented Reengineering © S. Demeyer, S.Ducasse, O. Nierstrasz Lecture 3 Radu Marinescu Detailed Model Capture  Details matter  Pay attention.
Chapter 5: Software Re-Engineering Omar Meqdadi SE 3860 Lecture 5 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Software Engineering Prof. Dr. Bertrand Meyer Dr. Manuel Oriol Dr. Bernd Schoeller Chair of Software Engineering Lectures 22: Legacy Software.
Requirement Engineering
Rational Unified Process Fundamentals Best Practices of Software Engineering Rational Unified Process Fundamentals Best Practices of Software Engineering.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
1 SYS366 Week 1 - Lecture 1 Introduction to Systems.
Chapter 6 Guidelines for Modelling. 1. The Modelling Process 1. Modelling as a Transformation Process 2. Basic Modelling Activities 3. Types of Modelling.
Methodology Overview 2 basics in user studies Lecture /slide deck produced by Saul Greenberg, University of Calgary, Canada Notice: some material in this.
Presentation transcript:

OORPT Object-Oriented Reengineering Patterns and Techniques 4. Reverse Engineering Prof. O. Nierstrasz

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.2 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.3 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.4 JEdit Experience  Make Money Inc. wants to make money  Make Money Inc. bought Jedit  Make Money Inc. wants to build a multimedia editor  Problem: Is it cheaper to extend JEdit or to write it from scratch?

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.5 JEdit: Different Approaches  Run the tool  Skim through the code  Look for duplication  Look at some classes/packages  Skim through the documentation  Recover the overall architecture (external tools, by hand)  Use metrics (external tools, custom tools)  Look for tests  Consider political issues

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.6 JEdit: Different Conclusions  9 teams: 2 extend, 7 write from scratch  Political: we already bought it, GPL license  Developed by one developer  Little refactoring  No interfaces  Important Classes: JEditTextArea, JEdit, Parser  Reusable: FileSystem, Plugin architecture  Documentation is so and so  …

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.7 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.8 What and Why ? Definition Reverse Engineering is the process of analysing a subject system —to identify the system’s components and their interrelationships and —create representations of the system in another form or at a higher level of abstraction. — Chikofsky & Cross, ’90 Motivation Understanding (other people’s) code (newcomers in the team, code reviewing, original developers left,...) Generating UML diagrams is NOT reverse engineering... but it is a valuable support tool Generating UML diagrams is NOT reverse engineering... but it is a valuable support tool

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.9 The Reengineering Life-Cycle (0) req. analysis (1) model capture issues scale speed accuracy politics (0) req. analysis (1) model capture issues scale speed accuracy politics Requirements Designs Code (0) requirement analysis (1) model capture (2) problem detection (3) problem resolution (4) program transformation

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.10 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.11 Forces — Setting Direction  Conflicting interests (technical, ergonomic, economic, political)  Presence/absence original developers  Legacy architecture  Which problems to tackle? —Interesting vs important problems? —Wrap, refactor or rewrite?

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.12 Setting Direction Agree on Maxims Set direction Appoint a Navigator Speak to the Round Table Maintain direction Coordinate direction Most Valuable First Where to start Fix Problems, Not Symptoms If It Ain't Broke Don't Fix It What not to do What to do Keep it Simple How to do it Principles & Guidelines for Software project management especially relevant for reengineering projects Principles & Guidelines for Software project management especially relevant for reengineering projects

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.13 Most Valuable First Problem: Which problems should you focus on first? Solution: Work on aspects that are most valuable to your customer  Maximize commitment, early results; build confidence  Difficulties and hints: —Which stakeholder do you listen to? —What measurable goal to aim for? —Consult change logs for high activity —Play the Planning Game —Wrap, refactor or rewrite? — Fix Problems, not Symptoms

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.14 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.15 Forces — First Contact  Legacy systems are large and complex —Split the system into manageable pieces  Time is scarce —Apply lightweight techniques to assess feasibility and risks  First impressions are dangerous —Always double-check your sources  People have different agendas —Build confidence; be wary of skeptics

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.16 First Contact System experts Chat with the Maintainers Interview during Demo Talk with developers Talk with end users Talk about it Verify what you hear feasibility assessment (one week time) feasibility assessment (one week time) Software System Read All the Code in One Hour Do a Mock Installation Read itCompile it Skim the Documentation Read about it

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.17 Solution: interview during demo -select several users -demo puts a user in a positive mindset -demo steers the interview Solution: interview during demo -select several users -demo puts a user in a positive mindset -demo steers the interview Interview during Demo Problem: What are the typical usage scenarios? Solution: Ask the user! ... however —Which user ? —Users complain —What should you ask ?

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.18 Chat with the Maintainers Problem: What are the history and politics of the legacy system? Solution: Discuss the problems with the system maintainers.  Documentation will mislead you (various reasons)  Stakeholders will mislead you (various reasons)  The maintainers know both the technical and political history

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.19 Chat with the Maintainers Questions to ask:  Easiest/hardest bug to fix in recent months?  How are change requests made and evaluated?  How did the development/maintenance team evolve during the project?  How good is the code? The documentation?  Why was the reengineering project started? What do you hope to gain? The major problems of our work are no so much technological as sociological. — DeMarco and Lister, Peopleware ‘99 The major problems of our work are no so much technological as sociological. — DeMarco and Lister, Peopleware ‘99

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.20 Read all the Code in One Hour Problem: How can you get a first impression of the quality of the source code? Solution: Scan all the code in single, short session.  Use a checklist (code review guidelines, coding styles etc.)  Look for functional tests and unit tests  Look for abstract classes and root classes that define domain abstractions  Beware of comments  Log all your questions! I took a course in speed reading and read “War and Peace” in twenty minutes. It’s about Russia. — Woody Allen I took a course in speed reading and read “War and Peace” in twenty minutes. It’s about Russia. — Woody Allen

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.21 First Project Plan Use standard templates, including:  project scope —see "Setting Direction"  opportunities —e.g., skilled maintainers, readable source-code, documentation  risks —e.g., absent test-suites, missing libraries, … —record likelihood (unlikely, possible, likely) & impact (high, moderate, low) for causing problems  go/no-go decision  activities —fish-eye view

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.22 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.23 Forces — Initial Understanding  Data is deceptive —Always double-check your sources  Understanding entails iteration —Plan iteration and feedback loops  Knowledge must be shared —“Put the map on the wall”  Teams need to communicate —“Use their language”

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.24 Initial Understanding understand  higher-level model understand  higher-level model Top down Speculate about Design Recover design Analyze the Persistent Data Study the Exceptional Entities Recover database Bottom up Identify problems

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.25 Speculate about Design Problem: How do you recover design from code? Solution: Develop hypotheses and check them  Develop a plausible class diagram and iteratively check and refine your design against the actual code. Variants:  Speculate about Business Objects  Speculate about Design Patterns  Speculate about Architecture

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.26 Study the Exceptional Entities Problem: How can you quickly identify design problems? Solution: Measure software entities and study the anomalous ones  Use simple metrics  Visualize metrics to get an overview  Browse the code to get insight into the anomalies

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.27 Visualizing Metrics (x,y) width height colour Use simple metrics and layout algorithms Visualizes up to 5 metrics per node

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.28 Initial Understanding (revisited) Top down Speculate about Design Analyze the Persistent Data Study the Exceptional Entities understand  higher-level model understand  higher-level model Bottom up ITERATION Recover design Recover database Identify problems

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.29 Roadmap  JEdit Experience  What and Why  Setting Direction —Most Valuable First  First Contact —Interview during Demo, Chat with Maintainers, Read all Code in One Hour  Initial Understanding —Speculate about Design, Study Exceptional Entities  Detailed Model Capture —Tie Code and Questions, Refactor to Understand, Step Through the Execution, Look for Contracts

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.30 Forces — Detailed Model Capture  Details matter —Pay attention to the details!  Design remains implicit —Record design rationale when you discover it!  Design evolves —Important issues are reflected in changes to the code!  Code only exposes static structure —Study dynamic behaviour to extract detailed design

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.31 Detailed Model Capture Expose the design & make sure it stays exposed Tie Code and Questions Refactor to Understand Keep track of your understanding Expose design Step through the Execution Expose collaborations Use Your Tools Look for Key Methods Look for Constructor Calls Look for Template/Hook Methods Look for Super Calls Use Your Tools Look for Key Methods Look for Constructor Calls Look for Template/Hook Methods Look for Super Calls Look for the Contracts Expose contracts Learn from the Past Expose evolution Write Tests to Understand

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.32 Tie Code and Questions Problem: How do you keep track of your understanding? Solution: Annotate the code  List questions, hypotheses, tasks and observations  Identify yourself!  Use conventions to locate/extract annotations  Annotate as comments, or as methods

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.33 Refactor to Understand Problem: How do you decipher cryptic code? Solution: Refactor it till it makes sense  Goal (for now) is to understand, not to reengineer  Work with a copy of the code  Refactoring requires an adequate test base —If this is missing, Write Tests to Understand Hints:  Rename attributes to convey roles  Rename methods and classes to reveal intent  Remove duplicated code  Replace condition branches by methods

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.34 Step Through the Execution Problem: How do you uncover the run-time architecture? Solution: Execute scenarios of known use cases and step through the code with a debugger  Tests can also be used as scenario generators —If tests are missing Write Tests to Understand  Put breakpoints in the code  Difficulties —OO source code exposes a class hierarchy, not the run-time object collaborations —Collaborations are spread throughout the code —Polymorphism may hide which classes are instantiated  Focused use of a debugger can expose collaborations

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.35 Look for the Contracts Problem: Which contracts does a class support? Solution: Look for common programming idioms  Look for “key methods” —Intention-revealing names —Key parameter types —Recurring parameter types represent temporary associations  Look for constructor calls  Look for Template/Hook methods  Look for super calls  Use your tools!

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.36 Learn from the Past Problem: How did the system get the way it is? Solution: Compare versions to discover where code was removed  Removed functionality is a sign of design evolution  Use or develop appropriate tools  Look for signs of: —Unstable design — repeated growth and refactoring —Mature design — growth, refactoring and stability

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.37 Conclusion  Setting Direction + First Contact —First Project Plan  Initial Understanding + Detailed Model Capture —Plan the work … and Work the plan —Frequent and Short Iterations  Issues —scale —speed vs. accuracy —politics

© Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Reverse Engineering 4.38 License > Attribution-ShareAlike 2.5 You are free: to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. Attribution-ShareAlike 2.5 You are free: to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above.