Software Reengineering & Evolution Schedule Goals What Is a Legacy
Total Page:16
File Type:pdf, Size:1020Kb
Schedule 1. Introduction Software Reengineering There are OO legacy systems too ! 2. Reverse Engineering & Evolution How to understand your code 3. Visualization Scalable approach 4. Dynamic Analysis To be really certain 5. Restructuring Serge Demeyer How to Refactor Your Code Stéphane Ducasse 6. Code Duplication Oscar Nierstrasz The most typical problems 7. Software Evolution Learn from the past January 2019 8. Going Agile Continuous Integration 9. Conclusion http://scg.unibe.ch/download/oorp/ © S. Demeyer, S. Ducasse, O. Nierstrasz Software Reengineering and Evolution.2 Goals What is a Legacy System ? We will try to convince you: “legacy” A sum of money, or a specified article, given to another by • Yes, Virginia, there are object-oriented legacy systems too! will; anything handed down by an ancestor or predecessor. • Reverse engineering and reengineering are essential — Oxford English Dictionary activities in the lifecycle of any successful software system. A legacy system is a piece of Typical problems with legacy systems: (And especially OO ones!) software that: • original developers not available • you have inherited, and • outdated development methods used • There is a large set of lightweight tools and techniques to • is valuable to you. • extensive patches and modifications have help you with reengineering. been made • missing or outdated documentation • Despite these tools and techniques, people must do job and they represent the most valuable resource. Þ so, further evolution and development may be prohibitively expensive © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.3 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.4 Software Maintenance - Cost Continuous Development Relative Cost Relative Maintenance Effort of Fixing Mistakes data from [Lien78a] Between 50% and 75% of x 200 17.4% Corrective (fixing reported errors) global effort is spent on “maintenance” ! 60.3% Perfective x 20 (new functionality) x 10 18.2% Adaptive Solution ? (new platforms or OS) • Better requirements engineering? x 5 • Better software methods & tools 4.1% Other (database schemas, CASE-tools, objects, x 1 components, …)? The bulk of the maintenance cost is due to new functionality requirement coding delivery Þ even with better requirements, it is hard to predict new functions design testing © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.5 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.6 Modern Methods & Tools ? Lehman's Laws [Glas98a] quoting empirical study from Sasa Dekleva (1992) A classic study by Lehman and Belady [Lehm85a] identified several “laws” of system change. • Modern methods(*) lead to more reliable software • Modern methods lead to less frequent software repair Continuing change • and ... • A program that is used in a real-world environment must change, or • Modern methods lead to more total maintenance time become progressively less useful in that environment. Contradiction ? No! Increasing complexity • modern methods make it easier to change • As a program evolves, it becomes more complex, and extra resources ... this capacity is used to enhance functionality! are needed to preserve and simplify its structure. (*) process-oriented structured methods, information engineering, data-oriented methods, prototyping, CASE-tools – not OO ! Those laws are still applicable… © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.7 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.8 What about Objects ? What about Components ? Object-oriented legacy systems • = successful OO systems whose architecture and design no longer responds to changing requirements Compared to traditional legacy systems • The symptoms and the source of the problems are the same • The technical details and solutions may differ OO techniques promise better • flexibility, • reusability, Þ they do not come for free • maintainability Components are very brittle … After a while one inevitably resorts to glue :) • … © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.9 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.10 Soccer Field Metaphor How to deal with Legacy ? • Assume 10 lines of code New or changing requirements will gradually degrade original design = 40 tiles of 1 x 1 cm … unless extra development effort is spent to adapt the structure • 12.5 million lines of code » 40 soccer fields New Functionality Hack it in ? Imagine 400 developers concurrently • duplicated code First … moving tiles around on 40 soccer fields • complex conditionals • refactor … • abusive inheritance • restructure • large classes/methods • reengineer A. van Deursen, De software-evolutieparadox Take a loan on your software Investment for the future Intreerede TU Delft, 23 feb 2005 Þ pay back via reengineering Þ paid back during maintenance ©© S. A. Demeyer, Van Deursen S. Ducasse, O. Nierstrasz Reengineering Legacy Systems.11 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.12 Common Symptoms The Reengineering Life-Cycle Lack of Knowledge Process symptoms (0) requirement Requirements • obsolete or no documentation • too long to turn things over to analysis • departure of the original production (2) problem developers or users • need for constant bug fixes (3) problem detection • disappearance of inside • maintenance dependencies resolution knowledge about the system • difficulties separating products Designs • limited understanding of entire Þsimple changes take too long system • people centric (1) model • lightweight Þmissing tests capture Code symptoms • duplicated code • code smells Code Þbig build times (4) program transformation © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.13 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.14 A Map of Reengineering Patterns 2. Reverse Engineering • What and Why Tests: Your Life Insurance • First Contact Detailed Model Capture Migration Strategies ☞ Interview during Demo • Initial Understanding Initial Understanding Detecting Duplicated Code Redistribute First Contact Responsibilities Transform Setting Direction Conditionals to Polymorphism © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.15 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.16 What and Why ? The Reengineering Life-Cycle Definition (0) requirement Reverse Engineering is the process of analysing a subject system Requirements analysis ☞ to identify the system’s components and their interrelationships and ☞ create representations of the system in another form or at a higher level of (2) problem (3) problem abstraction. — Chikofsky & Cross, ’90 detection resolution (0) req. analysis Motivation Designs (1) model capture Understanding other people’s code issues (cfr. newcomers in the team, code reviewing, (1) model • scale original developers left, ...) capture • speed • accuracy • politics Code Generating UML diagrams is NOT reverse engineering ... but it is a valuable support tool (4) program transformation © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.17 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.18 First Contact First Project Plan feasibility assessment Use standard templates, including: System experts (one week time) • project scope Talk with Talk with ☞ see "Setting Direction" end users developers • opportunities Chat with the Interview Talk about it ☞ e.g., skilled maintainers, readable source-code, documentation during Demo Maintainers • risks ☞ e.g., absent test-suites, missing libraries, … ☞ record likelihood (unlikely, possible, likely) Software System Verify what & impact (high, moderate, low) for causing problems you hear Read Read it Compile it • go/no-go decision about it • activities Read All the Code Skim the Do a Mock ☞ fish-eye view in One Hour Documentation Installation © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.19 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.20 Interview during Demo Initial Understanding Problem: What are the typical usage Top down scenarios? Recover design Solution: Ask the user! Speculate about Design • Solution: interview during demo - select several users understand Þ ITERATION - demo puts a user in a positive mindset higher-level model Study the - demo steers the interview Analyze the Exceptional • ... however Persistent Data Entities ☞ Which user ? ☞ Users complain Recover Identify database problems ☞ What should you ask ? Bottom up © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.21 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.22 3. Software Visualization The Reengineering Life-cycle • Introduction (0) requirement ☞ The Reengineering life-cycle Requirements analysis • Examples (2) problem (3) problem • Lightweight Approaches detection ☞ CodeCrawler resolution • Dynamic Analysis Designs (2) problem detection ☞ Key Concept Identification issues ☞ Feature Location (1) model • Tool support • Conclusion capture • Scalability • Efficiency Code (4) program transformation © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.23 © S. Demeyer, S. Ducasse, O. Nierstrasz Object-Oriented Reengineering.24 Visualising Hierarchies Bottom Up Visualisation • Euclidean cones ☞ Pros: All program entities and • More info than 2D relations ☞ Cons: • Lack of depth • Navigation • Hyperbolic trees ☞ Pros: • Good focus • Dynamic ☞ Cons: