Presentation is loading. Please wait.

Presentation is loading. Please wait.

OORPT Object-Oriented Reengineering Patterns and Techniques 1. Introduction Prof. O. Nierstrasz.

Similar presentations


Presentation on theme: "OORPT Object-Oriented Reengineering Patterns and Techniques 1. Introduction Prof. O. Nierstrasz."— Presentation transcript:

1 OORPT Object-Oriented Reengineering Patterns and Techniques 1. Introduction Prof. O. Nierstrasz

2 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.2 OORPT Lecturer Prof. Oscar Nierstrasz Oscar.Nierstrasz@iam.unibe.ch Schützenmattstr. 14/103, Tel. 031 631.4618 Assistants Dr. Tudor Gîrba, Adrian Kuhn Lectures IWI 001, Wednesdays @ 10h15-12h00 Exercises IWI 001, Wednesdays @ 12h00-13h00 WWW www.iam.unibe.ch/~scg/Teaching/OORPT/ Email listwww.iam.unibe.ch/mailman/listinfo/oorpt-vorlesung Text “Object-Oriented Reengineering Patterns,” Serge Demeyer, Stéphane Ducasse and Oscar Nierstrasz, Morgan Kaufmann and DPunkt, 2002, ISBN 1-55860-639-4.

3 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.3 Roadmap  Goals of this course  Why Reengineer? —Lehman's Laws —Object-Oriented Legacy  Typical Problems —common symptoms —architectural problems & refactoring opportunities  Reverse and Reengineering —Definitions —Techniques —Patterns

4 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.4 Roadmap  Goals of this course  Why Reengineer? —Lehman's Laws —Object-Oriented Legacy  Typical Problems —common symptoms —architectural problems & refactoring opportunities  Reverse and Reengineering —Definitions —Techniques —Patterns

5 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.5 Goals of this course We will try to convince you:  Yes, Virginia, there are object-oriented legacy systems too!  Reverse engineering and reengineering are essential activities in the lifecycle of any successful software system. (And especially OO ones!)  There is a large set of lightweight tools and techniques to help you with reengineering.  Despite these tools and techniques, people must do job and they represent the most valuable resource.

6 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.6 Course Schedule WeekDateLesson 125-Oct-06Introduction 21-Nov-06Lab — understanding legacy software 38-Nov-06Presentation of results (all groups) 415-Nov-06Reverse Engineering 522-Nov-06Visualization for Program Understanding 629-Nov-06Design Extraction and Visualization 76-Dec-06Problem Detection and Duplicated Code 813-Dec-06Restructuring 920-Dec-06Lab — using reengineering tools 1010-Jan-07Meta-modeling 1117-Jan-07Architectural Extraction 1224-Jan-07Testing and Migration Strategies 1331-Jan-07TBA 147-Feb-07Final Exam

7 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.7 Email list Please register yourself in the course mailing list! https://www.iam.unibe.ch/mailman/listinfo/oorpt-vorlesung

8 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.8 Roadmap  Goals of this course  Why Reengineer? —Lehman's Laws —Object-Oriented Legacy  Typical Problems —common symptoms —architectural problems & refactoring opportunities  Reverse and Reengineering —Definitions —Techniques —Patterns

9 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.9 What is a Legacy System ? “legacy” A sum of money, or a specified article, given to another by will; anything handed down by an ancestor or predecessor.— Oxford English Dictionary  so, further evolution and development may be prohibitively expensive A legacy system is a piece of software that: you have inherited, and is valuable to you. Typical problems with legacy systems: original developers not available outdated development methods used extensive patches and modifications have been made missing or outdated documentation

10 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.10 Software Maintenance - Cost requirement design coding testing delivery x 1 x 5 x 10 x 20 x 200 Relative Maintenance Effort Between 50% and 75% of global effort is spent on “maintenance” ! Relative Cost of Fixing Mistakes Solution ? Better requirements engineering? Better software methods & tools (database schemas, CASE-tools, objects, components, …)? Solution ? Better requirements engineering? Better software methods & tools (database schemas, CASE-tools, objects, components, …)?

11 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.11 Continuous Development 17.4% Corrective (fixing reported errors) 18.2% Adaptive (new platforms or OS) 60.3% Perfective (new functionality) The bulk of the maintenance cost is due to new functionality  even with better requirements, it is hard to predict new functions The bulk of the maintenance cost is due to new functionality  even with better requirements, it is hard to predict new functions data from [Lien78a] 4.1% Other

12 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.12 Lehman's Laws A classic study by Lehman and Belady [Lehm85a] identified several “laws” of system change. Continuing change  A program that is used in a real-world environment must change, or become progressively less useful in that environment. Increasing complexity  As a program evolves, it becomes more complex, and extra resources are needed to preserve and simplify its structure. Those laws are still applicable…

13 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.13 What about Objects ? 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,  maintainability  …  they do not come for free

14 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.14 What about Components ? Components can be very brittle … After a while one inevitably resorts to glue :-) Components can be very brittle … After a while one inevitably resorts to glue :-)

15 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.15 (*) process-oriented structured methods, information engineering, data-oriented methods, prototyping, CASE-tools – not OO ! Contradiction ?No! modern methods make it easier to change... this capacity is used to enhance functionality! Contradiction ?No! modern methods make it easier to change... this capacity is used to enhance functionality! Modern Methods & Tools ? [Glas98a] quoting empirical study from Sasa Dekleva (1992)  Modern methods (*) lead to more reliable software  Modern methods lead to less frequent software repair  and...  Modern methods lead to more total maintenance time

16 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.16 How to deal with Legacy ? New or changing requirements will gradually degrade original design … unless extra development effort is spent to adapt the structure New Functionality Hack it in ? duplicated code complex conditionals abusive inheritance large classes/methods First … refactor restructure reengineer Take a loan on your software  pay back via reengineering Take a loan on your software  pay back via reengineering Investment for the future  paid back during maintenance Investment for the future  paid back during maintenance

17 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.17 Roadmap  Goals of this course  Why Reengineer? —Lehman's Laws —Object-Oriented Legacy  Typical Problems —common symptoms —architectural problems & refactoring opportunities  Reverse and Reengineering —Definitions —Techniques —Patterns

18 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.18 Common Symptoms Lack of Knowledge  obsolete or no documentation  departure of the original developers or users  disappearance of inside knowledge about the system  limited understanding of entire system  missing tests Lack of Knowledge  obsolete or no documentation  departure of the original developers or users  disappearance of inside knowledge about the system  limited understanding of entire system  missing tests Process symptoms  too long to turn things over to production  need for constant bug fixes  maintenance dependencies  difficulties separating products  simple changes take too long Process symptoms  too long to turn things over to production  need for constant bug fixes  maintenance dependencies  difficulties separating products  simple changes take too long Code symptoms duplicated code code smells  big build times Code symptoms duplicated code code smells  big build times

19 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.19 Common Problems Architectural Problems  insufficient documentation = non-existent or out-of-date  improper layering = too few or too many layers  lack of modularity = strong coupling  duplicated code = copy, paste & edit code  duplicated functionality = similar functionality by separate teams Architectural Problems  insufficient documentation = non-existent or out-of-date  improper layering = too few or too many layers  lack of modularity = strong coupling  duplicated code = copy, paste & edit code  duplicated functionality = similar functionality by separate teams Refactoring opportunities  misuse of inheritance = code reuse vs polymorphism  missing inheritance = duplication, case-statements  misplaced operations = operations outside classes  violation of encapsulation = type-casting; C++ "friends"  class abuse = classes as namespaces Refactoring opportunities  misuse of inheritance = code reuse vs polymorphism  missing inheritance = duplication, case-statements  misplaced operations = operations outside classes  violation of encapsulation = type-casting; C++ "friends"  class abuse = classes as namespaces

20 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.20 FAMOOS Case Studies Different reengineering goals … but common themes and problems ! DomainLOCReengineering Goal pipeline planning55,000extract design user interface60,000increase flexibility embedded switching180,000improve modularity mail sorting350,000portability & scalability network management2,000,000unbundle application space mission2,500,000identify components

21 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.21 Roadmap  Goals of this course  Why Reengineer? —Lehman's Laws —Object-Oriented Legacy  Typical Problems —common symptoms —architectural problems & refactoring opportunities  Reverse and Reengineering —Definitions —Techniques —Patterns

22 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.22 Some Terminology “Forward Engineering is the traditional process of moving from high- level abstractions and logical, implementation-independent designs to the physical implementation of a system.” “Reverse Engineering is the process of analyzing 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.” “Reengineering... is the examination and alteration of a subject system to reconstitute it in a new form and the subsequent implementation of the new form.” — Chikofsky and Cross [in Arnold, 1993]

23 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.23 Goals of Reverse Engineering  Cope with complexity —need techniques to understand large, complex systems  Generate alternative views —automatically generate different ways to view systems  Recover lost information —extract what changes have been made and why  Detect side effects —help understand ramifications of changes  Synthesize higher abstractions —identify latent abstractions in software  Facilitate reuse —detect candidate reusable artifacts and components — Chikofsky and Cross [in Arnold, 1993]

24 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.24 Reverse Engineering Techniques  Redocumentation —pretty printers —diagram generators —cross-reference listing generators  Design recovery —software metrics —browsers, visualization tools —static analyzers —dynamic (trace) analyzers

25 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.25 Goals of Reengineering  Unbundling —split a monolithic system into parts that can be separately marketed  Performance —“first do it, then do it right, then do it fast” — experience shows this is the right sequence!  Port to other Platform —the architecture must distinguish the platform dependent modules  Design extraction —to improve maintainability, portability, etc.  Exploitation of New Technology —i.e., new language features, standards, libraries, etc.

26 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.26 Reengineering Techniques  Restructuring —automatic conversion from unstructured to structured code —source code translation — Chikofsky and Cross  Data reengineering —integrating and centralizing multiple databases —unifying multiple, inconsistent representations —upgrading data models — Sommerville, ch 32  Refactoring —renaming/moving methods/classes etc.

27 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.27 The Reengineering Life-Cycle Requirements Designs Code (0) requirement analysis (1) model capture (2) problem detection (3) problem resolution (4) program transformation people centric lightweight

28 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.28 Reverse engineering Patterns Reverse engineering patterns encode expertise and trade-offs in extracting design from source code, running systems and people. —Even if design documents exist, they are typically out of sync with reality. Example: Interview During Demo

29 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.29 Reengineering Patterns Reengineering patterns encode expertise and trade-offs in transforming legacy code to resolve problems that have emerged. —These problems are typically not apparent in original design but are due to architectural drift as requirements evolve Example: Move Behaviour Close to Data

30 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.30 A Map of Reengineering Patterns Tests: Your Life Insurance Detailed Model Capture Initial Understanding First Contact Setting Direction Migration Strategies Detecting Duplicated Code Redistribute Responsibilities Transform Conditionals to Polymorphism

31 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.31 Summary  Software “maintenance” is really continuous development  Object-oriented software also suffers from legacy symptoms  Reengineering goals differ; symptoms don’t  Common, lightweight techniques can be applied to keep software healthy

32 © Stéphane Ducasse, Serge Demeyer, Oscar Nierstrasz OORPT — Introduction 1.32 License > http://creativecommons.org/licenses/by-sa/2.5/ 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.


Download ppt "OORPT Object-Oriented Reengineering Patterns and Techniques 1. Introduction Prof. O. Nierstrasz."

Similar presentations


Ads by Google