SlideShare a Scribd company logo
1 of 70
Download to read offline
Devnology Lecture
Software Reengineering


Martin Pinzger
Software Engineering Research Group
Delft University of Technology
Greenfield software development




                                 2
Non-greenfield software development




            ?
                                     3
How often did you ...

... encounter greenfield and non-greenfield software
engineering?




                                                     4
Why non-greenfield engineering?

Because existing software, often called legacy software, is
valuable
  Often business-critical
  A huge amount of money has already been invested in it
  Has been tested and runs
  Does (mainly) what it should do



Would you replace such a system?




                                                              5
Why do we (often) start from a mess?




                                       6
Lehman’s Laws of software evolution

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.




For more information read Lehman and Belady, 1985



                                                                           7
Evolution of Mozilla source code




                                   8
Lehman’s Laws in practice

Existing software Is often modified in an ad-hoc manner (quick
fixes)
  Lack of time, resources, money, etc.


Initial good design is not maintained
  Spaghetti code, copy/paste programming, dependencies are introduced,
  no tests, etc.


Documentation is not updated (if there is one)
  Architecture and design documents


Original developers leave and with them their knowledge


                                                                         9
Typical result of such practices




                                   10
Implications of the results

Software maintenance costs continuously increase

Between 50% and 75% of global software development costs
are spent on maintenance!

Up to 60% of a maintenance effort is spent on understanding
the existing software




                                                              11
What is your decision?

            According to Lehman: “there will always be changes”




                                 hack it?




* duplicated code                              * first reengineer
* complex conditionals                         * then implement changes
* abusive inheritance
* large classes/methods



Take a loan on your software                   Investment for the future
pay back via reengineering                     paid back during maintenance
                                                                              12
Lecture Outline

Introduction

Reengineering Process

Module Capture/Reverse Engineering

Problem Detection

Summary and Conclusions




                                     13
Let’s reengineer

Definition:

“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.”

[Demeyer, Ducasse, Nierstrasz]
http://scg.unibe.ch/download/oorp/




                                                                14
Reengineering Life-Cycle


               (1) requirement    New
                    analysis      Requirements



 (3) problem
  detection                                      (4) problem
                                                  resolution

                        Designs


(2) model
 capture


                          Code


                                                               15
Goals of reengineering
                         Testability
                         Understandability
                         Modifiability
                         Extensibility
                         Maintainability
                         …




                                             16
Goals of reengineering (2)

Unbundling
  Split a monolithic system into parts that can be separately marketed


Performance
  “First do it, then do it right, then do it fast”


Design extraction
  To improve maintainability, portability, etc.


Exploitation of New Technology
  I.e., new language features, standards, libraries, etc.



                                                                         17
In this course, you will learn

Best practices to analyze and understand software systems
(i.e., reverse engineering)

Heuristics and tools to detect shortcomings in the design and
implementation of software systems




                                                                18
Model Capture
Reverse Engineering

Setting Direction
First Contact
Initial Understanding
Detailed Model Capture
Setting direction patterns

             Set direction


                                                            Where to start?
             Agree on Maxims
 Maintain                       Coordinate
 direction                        direction
                                                     Most Valuable First
    Appoint a            Speak to the
    Navigator            Round Table          What to do?                     What not to do?



                                              Fix Problems,           If It Ain't Broke
                                              Not Symptoms               Don't Fix It
Principles & guidelines for
software project management are
                                                      How to do it?
especially relevant for reengineering
projects
                                               Keep it Simple

                                                                                                20
Pattern: Most Valuable First

Problem: Which problems should you address first?




                                                   21
Most valuable first (2)

Solution: Work on aspects that are most valuable to your
customer
  Maximize commitment
  Deliver results early
  Build confidence




                                                           22
Most valuable first (3)




                         23
Most valuable first (4)

How do you tell what is valuable?
  Identify your customer
  Understand the customer’s business model
  Determine measurable goals
  Consult change logs for high activity
  Play the Planning Game
  Fix Problems, not Symptoms




                                             24
Most valuable first (5)

Planning Game




                         25
Model Capture
Reverse Engineering

Setting Direction
First Contact
Initial Understanding
Detailed Model Capture
What is Reverse Engineering and why?

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 [Chikofsky & Cross, ’90]

Motivation
  Understanding other people’s code, the design and architecture in order
  to maintain and evolve a software system




                                                                              27
First contact patterns

                                                                            feasibility assessment
                       System experts                                       (one week time)

  Talk with                                   Talk with
 developers                                   end users


      Chat with the Interview                                                         Talk about it
       Maintainers during Demo




                                                          Software System
         Verify what
          you hear                                Read about
                                    Read it                                          Compile it
                                                           it

                              Read All the Code   Skim the    Do a Mock
                                in One Hour     Documentation Installation


                                                                                                      28
Pattern: Read all the code in one hour

Problem: Yes, but… the system is so big! Where to start?




                                                           29
Read all the code in one hour (2)

Solution: Read the code in one hour

Focus on:
  Functional tests and unit tests
  Abstract classes and methods and classes high in the hierarchy
  Surprisingly large structures
  Comments
  Check classes with high fan-out
  Study the build process




                                                                   30
In Java programs focus on

public abstract class Example {    public interface IExample {
...                                ...
}                                  }


/**
                                   public class Test {
 * Block comment
                                     ...
 */
                                     @Test
public class Example {
                                     public void testExample() {
  public void foo() {
                                         ...
     int x = 1;
                                     }
     for (int x=1; i<100; i++) {
                                   }
       // do something comment
     }
  }
}




                                                                   31
First project plan

Project scope (1/2 page)
  Description, context, goals, verification criteria


Opportunities
  Identify factors to achieve project goals
    Skilled maintainers, readable source-code, documentation, etc.


Risks
  Identify risks that may cause problems
    Absent test-suites, missing libraries, etc.
  Record likelihood & impact for each risk


Go/no-go decision, activities (fish-eye view)
                                                                     32
Model Capture
Reverse Engineering

Setting Direction
First Contact
Initial Understanding
Detailed Model Capture
Initial understanding patterns
                            Top down
                                                 Recover
                                                  design
                               Speculate about Design


                                       ITERATION
     understand ⇒
   higher-level model
                           Analyze the                 Study the
                          Persistent Data          Exceptional Entities


                         Recover                                Identify
                        database                               problems
                                            Bottom up




                                                                           34
Study the exceptional entities

Problem: How can you quickly identify design problems?

Solution: Measure software entities and study the anomalous ones
  Visualize metrics to get an overview
  Use simple metrics
    Lines of code
    Number of methods
    ...




                                                               35
Example: Exceptional entities


                                Use simple
                                Use simple
                                metrics and
                                metrics and
                                layout
                                layout
                                algorithms
                                algorithms.


                                height     colour

                                   (x,y)   width

                                Visualize up
                                to 5 metrics
                                per node

                                                    36
Model Capture
Reverse Engineering

Setting Direction
First Contact
Initial Understanding
Detailed Model Capture
Detailed model capture patterns

       Tie Code and Questions                                Expose the design & make sure it
                                                             stays exposed
                                       Expose design
        Keep track of
     your understanding                   Refactor to Understand

                                     Expose collaborations
      Step through the Execution

                 Expose contracts                                            Write Tests
                                                                           to Understand
                      Look for the Contracts

•   Use Your Tools
•   Look for Key Methods                                     Expose evolution
•   Look for Constructor Calls
•   Look for Template/Hook Methods                                 Learn from the Past
•   Look for Super Calls



                                                                                                38
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

Hints
  Work with a copy of the code
  Refactoring requires an adequate test base
     If this is missing, “Write Tests to Understand”




                                                       39
Refactor to understand (cont.)

Guidelines
  Rename attributes to convey roles
  Rename methods and classes to reveal intent
  Remove duplicated code
  Replace condition branches by methods




                                                40
Learn from the past

Problem: How did the system get the way it is? Which parts are
stable and which aren’t?

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




                                                                 41
Examples: Unstable design




Pulsar: Repeated Modifications make it grow and shrink.
System Hotspot: Every System Version requires changes.




                                                          42
Reverse engineering tools/prototypes

X-Ray
  http://xray.inf.usi.ch/xray.php

DA4Java
  http://swerl.tudelft.nl/bin/view/MartinPinzger/MartinPinzgerDA4Java

Code City
  http://www.inf.usi.ch/phd/wettel/codecity.html




                                                                        43
X-Ray




        44
DA4Java




          45
CodeCity




           46
Summary Model Capture

Setting direction patterns to
  Set the goals
  Find the Go/No-Go decision
  Increase commitment of clients and developers


First contact patterns to
  Obtain an overview and grasp the main issues
  Assess the feasibility of the project

Initial Understanding & Detailed Model Capture
  Plan the work … and work the plan
  Frequent and short iterations

                                                  47
Problem Detection

In the Source Code
In the Evolution
Design problems

The most common design problems result from code that is


Unclear & complicated             Duplicated (code clones)




                                                             49
Code Smells (if it stinks, change it)

A code smell is a hint that something has gone wrong
somewhere in your code.

Duplicated Code
Long Method
Large Class
Long Parameter List
Divergent Change
Shotgun Surgery
Feature Envy
...


                                                       50
How to detect?

Measure and visualize quality aspects of the current
implementation of a system
  Source code metrics and structures


Measure and visualize quality aspects of the evolution of a
system
  Evolution metrics and structures


Use Polymetric Views




                                                              51
Polymetric Views

A combination of metrics and software
visualization                                         Entity
  Visualize software using colored rectangles for
  the entities and edges for the relationships         Relationship
  Render up to five metrics on one node:
    Size (1+2)
    Color (3)
    Position (4+5)
                                                        X Coordinate
                                             Y Coordinate
                                                               Color tone
                                                      Height
                                                                 Width

                                                                  7         52
Smell 1: Long Method

The longer a method is, the more difficult it is to understand
it.

When is a method too long?
  Heuristic: > 10 LOCs (?)


How to detect?
  Visualize LOC metric values of methods
  “Method Length Distribution View”




                                                                53
Method Length Distribution




                       Metrics:
                       Boxes: Methods
                       Width: LOC
                       Position-Y: LOC
                       Sort: LOC

                                         54
Smell 2: Switch Statement

Problem is similar to code duplication
  Switch statement is scattered in different places


How to detect?
  Visualize McCabe Cyclomatic Complexity metric to detect complex
  methods
  “Method Complexity Distribution View”




                                                                    55
Method Complexity




Metrics:
Boxes: Methods
Position-X: LOC
Position-Y: MCC
Sort: -
                    56
More info on Detection Strategies

Object-Oriented Metrics in Practice
Michele Lanza and Radu Marinescu, Springer 2006
http://www.springer.com/computer/swe/book/
978-3-540-24429-5




                                                  57
Tool for Smell Detection

inCode
 http://www.intooitus.com/inCode.html


jDeodorant
 http://java.uom.gr/~jdeodorant/




                                        58
Problem Detection

In the Source Code
In the Evolution
Understanding Evolution

Changes can point to design problems
  “Evolutionary Smells”


But
  Overwhelming complexity
  How can we detect and understand changes?


Solutions
  The Evolution Matrix
  The Kiviat Graphs




                                              60
Visualizing Class Evolution

Visualize classes as rectangles using for
width and height the following metrics:      Foo
  NOM (number of methods)
  NOA (number of attributes)                       Bar

The Classes can be categorized according
to their “personal evolution” and to their
“system evolution”

-> Evolution Patterns




                                                         61
The Evolution Matrix

                                  Removed Classes   Last Version




First Version



     Added
     Classes


       Major Leap




            Growth        Stabilisation
                     TIME (Versions)



                                                                   62
Evolution Patterns & Smells

Day-fly (Dead Code)
Persistent
Pulsar (Change Prone Entity)
SupernovaWhite Dwarf (Dead Code)
Red Giant (Large/God Class)
Idle (Dead Code)




                                   63
Persistent / Dayfly




                            Dayflies: Exists
                            during only one or
                            two versions. Perhaps
 Persistent: Has the same   an idea which was
 lifespan as the whole      tried out and then
 system. Part of the        dropped.
 original design. Perhaps
 holy dead code which no
 one dares to remove.




                                                    64
Pulsar / Supernova




 Pulsar: Repeated Modifications make it grow and shrink.
 System Hotspot: Every System Version requires changes.




 Supernova: Sudden increase in size. Possible Reasons:
 • Massive shift of functionality towards a class.
 • Data holder class for which it is easy to grow.
 • Sleeper: Developers knew exactly what to fill in.



                                                           65
White Dwarf / Red Giant / Idle




White Dwarf: Lost the functionality it had and now trundles along without
real meaning. Possibly dead code -> Lazy Class.




Red Giant: A permanent god (large) class which is always very large.



Idle: Keeps size over several versions. Possibly dead code,
possibly good code.


                                                                            66
Summary Problem Detection

Design Problems
  Result from duplicated, unclear, complicated source code
  -> Code Smells


Detection heuristics and Polymetric Views to detect code and
evolution smells




                                                               67
Conclusions

Object-Oriented Re-engineering Patterns
  Set of best practices to re-engineering software systems


Module Capture and Reverse Engineering
  Understand the design and implementation of software systems


Problem Detection
  Heuristics to detect Bad Smells in the source code and evolution of
  software systems


Next Step
  Add tests and refactor detected problems


                                                                        68
Reading material
                         Object-Oriented Reengineering Patterns
                         Serge Demeyer, Stephane Ducasse, and Oscar Nierstrasz
                         free copy from: http://scg.unibe.ch/download/oorp/



                                                  Working Effectively with Legacy Code
                                                  Michael Feathers, Prentice Hall, 1 edition, 2004




Refactoring to Patterns
Joshua Kerievsky, Addison-Wesley Professional, 2004
                                                                                                     69
Additional reading
                         Agile Software Development: Principles Patterns, and Practices
                         Robert C. Martin, Prentice Hall




                                                     Object-Oriented Design Heuristics
                                                     Arthur J. Riel, Prentice Hall, 1 edition, 1996




Refactoring: Improving the Design of Existing Code
Martin Fowler, Addison-Wesley Professional, 1999
                                                                                                      70

More Related Content

What's hot

Software evolution -- Good practices
Software evolution -- Good practicesSoftware evolution -- Good practices
Software evolution -- Good practicesNicolas Anquetil
 
eXtreme programming
eXtreme programmingeXtreme programming
eXtreme programmingJean Pаoli
 
Sdlc cource in_mumbai
Sdlc cource in_mumbaiSdlc cource in_mumbai
Sdlc cource in_mumbaivibrantuser
 
software engineering
software engineeringsoftware engineering
software engineeringramyavarkala
 
SE18_SE_Lec 12_ Project Management 1
SE18_SE_Lec 12_ Project Management 1SE18_SE_Lec 12_ Project Management 1
SE18_SE_Lec 12_ Project Management 1Amr E. Mohamed
 
Five benefits of agile practices in software intensive systems development
Five benefits of agile practices in software intensive systems developmentFive benefits of agile practices in software intensive systems development
Five benefits of agile practices in software intensive systems developmentIBM Rational software
 
Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010Joseph Yoder
 
SE2_Lec 19_Design Principles and Design Patterns
SE2_Lec 19_Design Principles and Design PatternsSE2_Lec 19_Design Principles and Design Patterns
SE2_Lec 19_Design Principles and Design PatternsAmr E. Mohamed
 
Agile Requirements by Agile Analysts
Agile Requirements by Agile AnalystsAgile Requirements by Agile Analysts
Agile Requirements by Agile AnalystsKurt Solarte
 
Software Engineering Solved Past Paper 2020
Software Engineering Solved Past Paper 2020 Software Engineering Solved Past Paper 2020
Software Engineering Solved Past Paper 2020 MuhammadTalha436
 
Extreme Programming (XP) as A Popular Agile methodology.
Extreme Programming (XP) as A Popular Agile methodology.Extreme Programming (XP) as A Popular Agile methodology.
Extreme Programming (XP) as A Popular Agile methodology.Ali Shaikh
 
Agile tour 2011 ralph jocham - scrum primer
Agile tour 2011   ralph jocham - scrum primerAgile tour 2011   ralph jocham - scrum primer
Agile tour 2011 ralph jocham - scrum primerAgora Group
 
Refactoring for Software Design Smells Book - A Visual Overview
Refactoring for Software Design Smells Book - A Visual OverviewRefactoring for Software Design Smells Book - A Visual Overview
Refactoring for Software Design Smells Book - A Visual OverviewGanesh Samarthyam
 

What's hot (20)

Software evolution -- Good practices
Software evolution -- Good practicesSoftware evolution -- Good practices
Software evolution -- Good practices
 
eXtreme programming
eXtreme programmingeXtreme programming
eXtreme programming
 
Feasible
FeasibleFeasible
Feasible
 
Sdlc cource in_mumbai
Sdlc cource in_mumbaiSdlc cource in_mumbai
Sdlc cource in_mumbai
 
software engineering
software engineeringsoftware engineering
software engineering
 
The Agile PMP v2
The Agile PMP v2The Agile PMP v2
The Agile PMP v2
 
Adopting Agile
Adopting  AgileAdopting  Agile
Adopting Agile
 
Incremental
IncrementalIncremental
Incremental
 
SE18_SE_Lec 12_ Project Management 1
SE18_SE_Lec 12_ Project Management 1SE18_SE_Lec 12_ Project Management 1
SE18_SE_Lec 12_ Project Management 1
 
Five benefits of agile practices in software intensive systems development
Five benefits of agile practices in software intensive systems developmentFive benefits of agile practices in software intensive systems development
Five benefits of agile practices in software intensive systems development
 
Agile.usability
Agile.usabilityAgile.usability
Agile.usability
 
Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010Refactoring AOMs For AgilePT2010
Refactoring AOMs For AgilePT2010
 
SE2_Lec 19_Design Principles and Design Patterns
SE2_Lec 19_Design Principles and Design PatternsSE2_Lec 19_Design Principles and Design Patterns
SE2_Lec 19_Design Principles and Design Patterns
 
Heuristic evaluation unbranded
Heuristic evaluation unbrandedHeuristic evaluation unbranded
Heuristic evaluation unbranded
 
Agile Requirements by Agile Analysts
Agile Requirements by Agile AnalystsAgile Requirements by Agile Analysts
Agile Requirements by Agile Analysts
 
Software Engineering Solved Past Paper 2020
Software Engineering Solved Past Paper 2020 Software Engineering Solved Past Paper 2020
Software Engineering Solved Past Paper 2020
 
Xp
XpXp
Xp
 
Extreme Programming (XP) as A Popular Agile methodology.
Extreme Programming (XP) as A Popular Agile methodology.Extreme Programming (XP) as A Popular Agile methodology.
Extreme Programming (XP) as A Popular Agile methodology.
 
Agile tour 2011 ralph jocham - scrum primer
Agile tour 2011   ralph jocham - scrum primerAgile tour 2011   ralph jocham - scrum primer
Agile tour 2011 ralph jocham - scrum primer
 
Refactoring for Software Design Smells Book - A Visual Overview
Refactoring for Software Design Smells Book - A Visual OverviewRefactoring for Software Design Smells Book - A Visual Overview
Refactoring for Software Design Smells Book - A Visual Overview
 

Similar to Devnology back toschool software reengineering

Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1Jorge Boria
 
Software development philosophies v1
Software development philosophies v1Software development philosophies v1
Software development philosophies v1Praveen Nair
 
Software Engineering The Multiview Approach And Wisdm
Software Engineering   The Multiview Approach And WisdmSoftware Engineering   The Multiview Approach And Wisdm
Software Engineering The Multiview Approach And Wisdmguestc990b6
 
SE2018_Lec 18_ Design Principles and Design Patterns
SE2018_Lec 18_ Design Principles and Design PatternsSE2018_Lec 18_ Design Principles and Design Patterns
SE2018_Lec 18_ Design Principles and Design PatternsAmr E. Mohamed
 
Soft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptxSoft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptxKalpna Saharan
 
OO Development 2 - Software Development Methodologies
OO Development 2 - Software Development MethodologiesOO Development 2 - Software Development Methodologies
OO Development 2 - Software Development MethodologiesRandy Connolly
 
04 designing architectures
04 designing architectures04 designing architectures
04 designing architecturesMajong DevJfu
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseKenan Sevindik
 
Software Engineering- Crisis and Process Models
Software Engineering- Crisis and Process ModelsSoftware Engineering- Crisis and Process Models
Software Engineering- Crisis and Process ModelsNishu Rastogi
 
Periodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and PracticesPeriodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and PracticesJérôme Kehrli
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answersHopeTutors1
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering noteNeelamani Samal
 
software engineering notes for cse/it fifth semester
software engineering notes for cse/it fifth semestersoftware engineering notes for cse/it fifth semester
software engineering notes for cse/it fifth semesterrajesh199155
 
extreme Programming
extreme Programmingextreme Programming
extreme ProgrammingBilal Shah
 
Introduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptxIntroduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptxaasssss1
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship ChecklistRyan Polk
 
Modern software architect post the agile wave
Modern software architect post the agile waveModern software architect post the agile wave
Modern software architect post the agile waveNiels Bech Nielsen
 
Chapter1 Advanced Software Engineering overview
Chapter1 Advanced Software Engineering overviewChapter1 Advanced Software Engineering overview
Chapter1 Advanced Software Engineering overviewBule Hora University
 

Similar to Devnology back toschool software reengineering (20)

Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1
 
Software development philosophies v1
Software development philosophies v1Software development philosophies v1
Software development philosophies v1
 
Software Engineering The Multiview Approach And Wisdm
Software Engineering   The Multiview Approach And WisdmSoftware Engineering   The Multiview Approach And Wisdm
Software Engineering The Multiview Approach And Wisdm
 
SE2018_Lec 18_ Design Principles and Design Patterns
SE2018_Lec 18_ Design Principles and Design PatternsSE2018_Lec 18_ Design Principles and Design Patterns
SE2018_Lec 18_ Design Principles and Design Patterns
 
Soft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptxSoft.Engg. UNIT 1.pptx
Soft.Engg. UNIT 1.pptx
 
HCI Chapter_2.ppt
HCI Chapter_2.pptHCI Chapter_2.ppt
HCI Chapter_2.ppt
 
HCI Chapter_2.pdf
HCI Chapter_2.pdfHCI Chapter_2.pdf
HCI Chapter_2.pdf
 
OO Development 2 - Software Development Methodologies
OO Development 2 - Software Development MethodologiesOO Development 2 - Software Development Methodologies
OO Development 2 - Software Development Methodologies
 
04 designing architectures
04 designing architectures04 designing architectures
04 designing architectures
 
Contemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With EnterpriseContemporary Software Engineering Practices Together With Enterprise
Contemporary Software Engineering Practices Together With Enterprise
 
Software Engineering- Crisis and Process Models
Software Engineering- Crisis and Process ModelsSoftware Engineering- Crisis and Process Models
Software Engineering- Crisis and Process Models
 
Periodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and PracticesPeriodic Table of Agile Principles and Practices
Periodic Table of Agile Principles and Practices
 
DevOps interview questions and answers
DevOps interview questions and answersDevOps interview questions and answers
DevOps interview questions and answers
 
Software engineering note
Software engineering noteSoftware engineering note
Software engineering note
 
software engineering notes for cse/it fifth semester
software engineering notes for cse/it fifth semestersoftware engineering notes for cse/it fifth semester
software engineering notes for cse/it fifth semester
 
extreme Programming
extreme Programmingextreme Programming
extreme Programming
 
Introduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptxIntroduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptx
 
Code Craftsmanship Checklist
Code Craftsmanship ChecklistCode Craftsmanship Checklist
Code Craftsmanship Checklist
 
Modern software architect post the agile wave
Modern software architect post the agile waveModern software architect post the agile wave
Modern software architect post the agile wave
 
Chapter1 Advanced Software Engineering overview
Chapter1 Advanced Software Engineering overviewChapter1 Advanced Software Engineering overview
Chapter1 Advanced Software Engineering overview
 

More from Devnology

What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?Devnology
 
Meetup at SIG: Meten is weten
Meetup at SIG: Meten is wetenMeetup at SIG: Meten is weten
Meetup at SIG: Meten is wetenDevnology
 
Software Operation Knowledge
Software Operation KnowledgeSoftware Operation Knowledge
Software Operation KnowledgeDevnology
 
Slides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWISlides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWIDevnology
 
Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205Devnology
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applicationsDevnology
 
Hacking Smartcards & RFID
Hacking Smartcards & RFIDHacking Smartcards & RFID
Hacking Smartcards & RFIDDevnology
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
Devnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software DevelopmentDevnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software DevelopmentDevnology
 
Devnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en ArchitectuurDevnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en ArchitectuurDevnology
 
Devnology Back to School III : Software impact
Devnology Back to School III : Software impactDevnology Back to School III : Software impact
Devnology Back to School III : Software impactDevnology
 
Introduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software VolcanoIntroduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software VolcanoDevnology
 
Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology
 
Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011Devnology
 
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Spoofax: ontwikkeling van domeinspecifieke talen in EclipseSpoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Spoofax: ontwikkeling van domeinspecifieke talen in EclipseDevnology
 
Experimenting with Augmented Reality
Experimenting with Augmented RealityExperimenting with Augmented Reality
Experimenting with Augmented RealityDevnology
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightDevnology
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
 
Devnology Fitnesse workshop
Devnology Fitnesse workshopDevnology Fitnesse workshop
Devnology Fitnesse workshopDevnology
 

More from Devnology (20)

What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?What do we really know about the differences between static and dynamic types?
What do we really know about the differences between static and dynamic types?
 
Meetup at SIG: Meten is weten
Meetup at SIG: Meten is wetenMeetup at SIG: Meten is weten
Meetup at SIG: Meten is weten
 
Software Operation Knowledge
Software Operation KnowledgeSoftware Operation Knowledge
Software Operation Knowledge
 
Slides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWISlides Felienne Hermans Symposium EWI
Slides Felienne Hermans Symposium EWI
 
Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205Devnology auteursrecht en open source 20130205
Devnology auteursrecht en open source 20130205
 
The top 10 security issues in web applications
The top 10 security issues in web applicationsThe top 10 security issues in web applications
The top 10 security issues in web applications
 
Hacking Smartcards & RFID
Hacking Smartcards & RFIDHacking Smartcards & RFID
Hacking Smartcards & RFID
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Devnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software DevelopmentDevnology Back to School: Empirical Evidence on Modeling in Software Development
Devnology Back to School: Empirical Evidence on Modeling in Software Development
 
Devnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en ArchitectuurDevnology Back to School IV - Agility en Architectuur
Devnology Back to School IV - Agility en Architectuur
 
Devnology Back to School III : Software impact
Devnology Back to School III : Software impactDevnology Back to School III : Software impact
Devnology Back to School III : Software impact
 
Introduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software VolcanoIntroduction to Software Evolution: The Software Volcano
Introduction to Software Evolution: The Software Volcano
 
Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011Devnology Workshop Genpro 2 feb 2011
Devnology Workshop Genpro 2 feb 2011
 
Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011Devnology Coding Dojo 05-01-2011
Devnology Coding Dojo 05-01-2011
 
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Spoofax: ontwikkeling van domeinspecifieke talen in EclipseSpoofax: ontwikkeling van domeinspecifieke talen in Eclipse
Spoofax: ontwikkeling van domeinspecifieke talen in Eclipse
 
Experimenting with Augmented Reality
Experimenting with Augmented RealityExperimenting with Augmented Reality
Experimenting with Augmented Reality
 
Unit testing and MVVM in Silverlight
Unit testing and MVVM in SilverlightUnit testing and MVVM in Silverlight
Unit testing and MVVM in Silverlight
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
Devnology Fitnesse workshop
Devnology Fitnesse workshopDevnology Fitnesse workshop
Devnology Fitnesse workshop
 

Recently uploaded

Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechProduct School
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationKnoldus Inc.
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdfThe Good Food Institute
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNeo4j
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.IPLOOK Networks
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applicationsnooralam814309
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)IES VE
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptxHansamali Gamage
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch TuesdayIvanti
 
20140402 - Smart house demo kit
20140402 - Smart house demo kit20140402 - Smart house demo kit
20140402 - Smart house demo kitJamie (Taka) Wang
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc
 
LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0DanBrown980551
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1DianaGray10
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FESTBillieHyde
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInThousandEyes
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfInfopole1
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingFrancesco Corti
 

Recently uploaded (20)

Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - TechWebinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
Webinar: The Art of Prioritizing Your Product Roadmap by AWS Sr PM - Tech
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its application
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf
 
Novo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4jNovo Nordisk's journey in developing an open-source application on Neo4j
Novo Nordisk's journey in developing an open-source application on Neo4j
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applications
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)
 
.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx.NET 8 ChatBot with Azure OpenAI Services.pptx
.NET 8 ChatBot with Azure OpenAI Services.pptx
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
 
20140402 - Smart house demo kit
20140402 - Smart house demo kit20140402 - Smart house demo kit
20140402 - Smart house demo kit
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
 
LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0LF Energy Webinar - Unveiling OpenEEMeter 4.0
LF Energy Webinar - Unveiling OpenEEMeter 4.0
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FEST
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdf
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is going
 

Devnology back toschool software reengineering

  • 1. Devnology Lecture Software Reengineering Martin Pinzger Software Engineering Research Group Delft University of Technology
  • 4. How often did you ... ... encounter greenfield and non-greenfield software engineering? 4
  • 5. Why non-greenfield engineering? Because existing software, often called legacy software, is valuable Often business-critical A huge amount of money has already been invested in it Has been tested and runs Does (mainly) what it should do Would you replace such a system? 5
  • 6. Why do we (often) start from a mess? 6
  • 7. Lehman’s Laws of software evolution 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. For more information read Lehman and Belady, 1985 7
  • 8. Evolution of Mozilla source code 8
  • 9. Lehman’s Laws in practice Existing software Is often modified in an ad-hoc manner (quick fixes) Lack of time, resources, money, etc. Initial good design is not maintained Spaghetti code, copy/paste programming, dependencies are introduced, no tests, etc. Documentation is not updated (if there is one) Architecture and design documents Original developers leave and with them their knowledge 9
  • 10. Typical result of such practices 10
  • 11. Implications of the results Software maintenance costs continuously increase Between 50% and 75% of global software development costs are spent on maintenance! Up to 60% of a maintenance effort is spent on understanding the existing software 11
  • 12. What is your decision? According to Lehman: “there will always be changes” hack it? * duplicated code * first reengineer * complex conditionals * then implement changes * abusive inheritance * large classes/methods Take a loan on your software Investment for the future pay back via reengineering paid back during maintenance 12
  • 13. Lecture Outline Introduction Reengineering Process Module Capture/Reverse Engineering Problem Detection Summary and Conclusions 13
  • 14. Let’s reengineer Definition: “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.” [Demeyer, Ducasse, Nierstrasz] http://scg.unibe.ch/download/oorp/ 14
  • 15. Reengineering Life-Cycle (1) requirement New analysis Requirements (3) problem detection (4) problem resolution Designs (2) model capture Code 15
  • 16. Goals of reengineering Testability Understandability Modifiability Extensibility Maintainability … 16
  • 17. Goals of reengineering (2) Unbundling Split a monolithic system into parts that can be separately marketed Performance “First do it, then do it right, then do it fast” Design extraction To improve maintainability, portability, etc. Exploitation of New Technology I.e., new language features, standards, libraries, etc. 17
  • 18. In this course, you will learn Best practices to analyze and understand software systems (i.e., reverse engineering) Heuristics and tools to detect shortcomings in the design and implementation of software systems 18
  • 19. Model Capture Reverse Engineering Setting Direction First Contact Initial Understanding Detailed Model Capture
  • 20. Setting direction patterns Set direction Where to start? Agree on Maxims Maintain Coordinate direction direction Most Valuable First Appoint a Speak to the Navigator Round Table What to do? What not to do? Fix Problems, If It Ain't Broke Not Symptoms Don't Fix It Principles & guidelines for software project management are How to do it? especially relevant for reengineering projects Keep it Simple 20
  • 21. Pattern: Most Valuable First Problem: Which problems should you address first? 21
  • 22. Most valuable first (2) Solution: Work on aspects that are most valuable to your customer Maximize commitment Deliver results early Build confidence 22
  • 24. Most valuable first (4) How do you tell what is valuable? Identify your customer Understand the customer’s business model Determine measurable goals Consult change logs for high activity Play the Planning Game Fix Problems, not Symptoms 24
  • 25. Most valuable first (5) Planning Game 25
  • 26. Model Capture Reverse Engineering Setting Direction First Contact Initial Understanding Detailed Model Capture
  • 27. What is Reverse Engineering and why? 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 [Chikofsky & Cross, ’90] Motivation Understanding other people’s code, the design and architecture in order to maintain and evolve a software system 27
  • 28. First contact patterns feasibility assessment System experts (one week time) Talk with Talk with developers end users Chat with the Interview Talk about it Maintainers during Demo Software System Verify what you hear Read about Read it Compile it it Read All the Code Skim the Do a Mock in One Hour Documentation Installation 28
  • 29. Pattern: Read all the code in one hour Problem: Yes, but… the system is so big! Where to start? 29
  • 30. Read all the code in one hour (2) Solution: Read the code in one hour Focus on: Functional tests and unit tests Abstract classes and methods and classes high in the hierarchy Surprisingly large structures Comments Check classes with high fan-out Study the build process 30
  • 31. In Java programs focus on public abstract class Example { public interface IExample { ... ... } } /** public class Test { * Block comment ... */ @Test public class Example { public void testExample() { public void foo() { ... int x = 1; } for (int x=1; i<100; i++) { } // do something comment } } } 31
  • 32. First project plan Project scope (1/2 page) Description, context, goals, verification criteria Opportunities Identify factors to achieve project goals Skilled maintainers, readable source-code, documentation, etc. Risks Identify risks that may cause problems Absent test-suites, missing libraries, etc. Record likelihood & impact for each risk Go/no-go decision, activities (fish-eye view) 32
  • 33. Model Capture Reverse Engineering Setting Direction First Contact Initial Understanding Detailed Model Capture
  • 34. Initial understanding patterns Top down Recover design Speculate about Design ITERATION understand ⇒ higher-level model Analyze the Study the Persistent Data Exceptional Entities Recover Identify database problems Bottom up 34
  • 35. Study the exceptional entities Problem: How can you quickly identify design problems? Solution: Measure software entities and study the anomalous ones Visualize metrics to get an overview Use simple metrics Lines of code Number of methods ... 35
  • 36. Example: Exceptional entities Use simple Use simple metrics and metrics and layout layout algorithms algorithms. height colour (x,y) width Visualize up to 5 metrics per node 36
  • 37. Model Capture Reverse Engineering Setting Direction First Contact Initial Understanding Detailed Model Capture
  • 38. Detailed model capture patterns Tie Code and Questions Expose the design & make sure it stays exposed Expose design Keep track of your understanding Refactor to Understand Expose collaborations Step through the Execution Expose contracts Write Tests to Understand Look for the Contracts • Use Your Tools • Look for Key Methods Expose evolution • Look for Constructor Calls • Look for Template/Hook Methods Learn from the Past • Look for Super Calls 38
  • 39. 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 Hints Work with a copy of the code Refactoring requires an adequate test base If this is missing, “Write Tests to Understand” 39
  • 40. Refactor to understand (cont.) Guidelines Rename attributes to convey roles Rename methods and classes to reveal intent Remove duplicated code Replace condition branches by methods 40
  • 41. Learn from the past Problem: How did the system get the way it is? Which parts are stable and which aren’t? 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 41
  • 42. Examples: Unstable design Pulsar: Repeated Modifications make it grow and shrink. System Hotspot: Every System Version requires changes. 42
  • 43. Reverse engineering tools/prototypes X-Ray http://xray.inf.usi.ch/xray.php DA4Java http://swerl.tudelft.nl/bin/view/MartinPinzger/MartinPinzgerDA4Java Code City http://www.inf.usi.ch/phd/wettel/codecity.html 43
  • 44. X-Ray 44
  • 45. DA4Java 45
  • 46. CodeCity 46
  • 47. Summary Model Capture Setting direction patterns to Set the goals Find the Go/No-Go decision Increase commitment of clients and developers First contact patterns to Obtain an overview and grasp the main issues Assess the feasibility of the project Initial Understanding & Detailed Model Capture Plan the work … and work the plan Frequent and short iterations 47
  • 48. Problem Detection In the Source Code In the Evolution
  • 49. Design problems The most common design problems result from code that is Unclear & complicated Duplicated (code clones) 49
  • 50. Code Smells (if it stinks, change it) A code smell is a hint that something has gone wrong somewhere in your code. Duplicated Code Long Method Large Class Long Parameter List Divergent Change Shotgun Surgery Feature Envy ... 50
  • 51. How to detect? Measure and visualize quality aspects of the current implementation of a system Source code metrics and structures Measure and visualize quality aspects of the evolution of a system Evolution metrics and structures Use Polymetric Views 51
  • 52. Polymetric Views A combination of metrics and software visualization Entity Visualize software using colored rectangles for the entities and edges for the relationships Relationship Render up to five metrics on one node: Size (1+2) Color (3) Position (4+5) X Coordinate Y Coordinate Color tone Height Width 7 52
  • 53. Smell 1: Long Method The longer a method is, the more difficult it is to understand it. When is a method too long? Heuristic: > 10 LOCs (?) How to detect? Visualize LOC metric values of methods “Method Length Distribution View” 53
  • 54. Method Length Distribution Metrics: Boxes: Methods Width: LOC Position-Y: LOC Sort: LOC 54
  • 55. Smell 2: Switch Statement Problem is similar to code duplication Switch statement is scattered in different places How to detect? Visualize McCabe Cyclomatic Complexity metric to detect complex methods “Method Complexity Distribution View” 55
  • 57. More info on Detection Strategies Object-Oriented Metrics in Practice Michele Lanza and Radu Marinescu, Springer 2006 http://www.springer.com/computer/swe/book/ 978-3-540-24429-5 57
  • 58. Tool for Smell Detection inCode http://www.intooitus.com/inCode.html jDeodorant http://java.uom.gr/~jdeodorant/ 58
  • 59. Problem Detection In the Source Code In the Evolution
  • 60. Understanding Evolution Changes can point to design problems “Evolutionary Smells” But Overwhelming complexity How can we detect and understand changes? Solutions The Evolution Matrix The Kiviat Graphs 60
  • 61. Visualizing Class Evolution Visualize classes as rectangles using for width and height the following metrics: Foo NOM (number of methods) NOA (number of attributes) Bar The Classes can be categorized according to their “personal evolution” and to their “system evolution” -> Evolution Patterns 61
  • 62. The Evolution Matrix Removed Classes Last Version First Version Added Classes Major Leap Growth Stabilisation TIME (Versions) 62
  • 63. Evolution Patterns & Smells Day-fly (Dead Code) Persistent Pulsar (Change Prone Entity) SupernovaWhite Dwarf (Dead Code) Red Giant (Large/God Class) Idle (Dead Code) 63
  • 64. Persistent / Dayfly Dayflies: Exists during only one or two versions. Perhaps Persistent: Has the same an idea which was lifespan as the whole tried out and then system. Part of the dropped. original design. Perhaps holy dead code which no one dares to remove. 64
  • 65. Pulsar / Supernova Pulsar: Repeated Modifications make it grow and shrink. System Hotspot: Every System Version requires changes. Supernova: Sudden increase in size. Possible Reasons: • Massive shift of functionality towards a class. • Data holder class for which it is easy to grow. • Sleeper: Developers knew exactly what to fill in. 65
  • 66. White Dwarf / Red Giant / Idle White Dwarf: Lost the functionality it had and now trundles along without real meaning. Possibly dead code -> Lazy Class. Red Giant: A permanent god (large) class which is always very large. Idle: Keeps size over several versions. Possibly dead code, possibly good code. 66
  • 67. Summary Problem Detection Design Problems Result from duplicated, unclear, complicated source code -> Code Smells Detection heuristics and Polymetric Views to detect code and evolution smells 67
  • 68. Conclusions Object-Oriented Re-engineering Patterns Set of best practices to re-engineering software systems Module Capture and Reverse Engineering Understand the design and implementation of software systems Problem Detection Heuristics to detect Bad Smells in the source code and evolution of software systems Next Step Add tests and refactor detected problems 68
  • 69. Reading material Object-Oriented Reengineering Patterns Serge Demeyer, Stephane Ducasse, and Oscar Nierstrasz free copy from: http://scg.unibe.ch/download/oorp/ Working Effectively with Legacy Code Michael Feathers, Prentice Hall, 1 edition, 2004 Refactoring to Patterns Joshua Kerievsky, Addison-Wesley Professional, 2004 69
  • 70. Additional reading Agile Software Development: Principles Patterns, and Practices Robert C. Martin, Prentice Hall Object-Oriented Design Heuristics Arthur J. Riel, Prentice Hall, 1 edition, 1996 Refactoring: Improving the Design of Existing Code Martin Fowler, Addison-Wesley Professional, 1999 70