Top Banner
Reverse Engineering and Design Recovery Informatics 122 Alex Baker
70

Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Dec 30, 2015

Download

Documents

Moris Hudson
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Reverse Engineering and Design RecoveryInformatics 122

Alex Baker

Page 2: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Definitions Reverse Engineering: Analyzing a system to:

1. Identify its components and their relationships

2. Create representations in another form Usually refers to redocumentation

Design Recovery A subset of reverse engineering A higher level understanding

(Chikofsky and Cross, 1990)

Page 3: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Also like a double-waterfall…

General model for recovery (Byrne, 1992)

Existing System Target System

Implementation

Design

Requirements Requirements

Con-ceptual

Con-ceptual

Design

Implementation

re-think

re-specify

re-design

re-build

Alteration

ReverseEngineeringAbstraction

ForwardEngineeringRefinement

Page 4: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What is the Design?

The basicsBeast and Superbeast classesAI classesData structureEngine structure

Page 5: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What is the Design?

We want a game based on Beast We want it to be expandable We must be able to add more monsters To enact this we want to use interfaces A lot of this is enacted through pushable Pushable is used by the engine to…

Page 6: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What if we want to…

Change the double-beast-push behavior

Add a new monster type

Let the player climb on top of blocks

Simplify the design

Page 7: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What is the Design?

The basicsBeast and Superbeast classesAI classesData structureEngine structure

Page 8: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What is the Design?

We want a game based on Beast We want it to be expandable We must be able to add more monsters To enact this we want to use interfaces A lot of this is enacted through pushable Pushable is used by the engine to…

Page 9: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What do we use?

Reverse engineering recreates design abstractions from Code Existing design documentation (if available)

Personal experience / general knowledge about problem and application domains

Talking to people

(Biggerstaff, 1989)

Page 10: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What do we Create? Recovered abstractions need:

Formal specifications Module breakdowns Data abstractions Dataflows Informal knowledge

All information required to understand What How Why

(Biggerstaff, 1989)

Page 11: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Why do we have to do this?

Page 12: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Why do we have to do this? Working with others’ code…

Debugging

Maintenance Modification Reuse

Working with your own code

You will work with code in the absence of a design

Page 13: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: No design

Lost design Build-and-fixed Agile methodologies

Incomprehensible design

Page 14: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Page 15: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Design not followed

Page 16: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Design deviations

Page 17: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Design deviations

Page 18: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Design deviations

?

Page 19: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

Design deviations

Page 20: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

???

Motivation: Design Drift

Design deviations

???

Page 21: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

???

Motivation: Design Drift

Design deviations

???

Page 22: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

???

Motivation: Design Drift

Design deviations

???

Page 23: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

???

Motivation: Design Drift

Design deviations

???

Page 24: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Motivation: Design Drift

You’re often recovering, in some sense

Page 25: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Deviations happen

Sometimes you’re formally making a spec

Sometimes you’re just trying to figure out what the heck someone was thinking…

Page 26: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What are the Goals of RE

Cope with complexity Generate alternate views Recover lost information

Detect side effects Synthesize higher abstractions Facilitate Reuse

(Chikofsky and Cross, 1990)

Page 27: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

What are the Goals of RE

Cope with complexity Generate alternate views Recover lost information

Detect side effects Synthesize higher abstractions Facilitate Reuse

Redocumentation

Design Recovery

Page 28: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

All this code

What does it mean?

Page 29: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

So lets start with the basics

Recreating the structure (redocumentation)

Existing System Target System

Implementation

Design

Requirements Requirements

Con-ceptual

Con-ceptual

Design

Implementation

re-think

re-specify

re-design

re-build

Alteration

ReverseEngineeringAbstraction

ForwardEngineeringRefinement

Page 30: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Object Orientation

Something of an advantageClass names, function namesEstablished relationships (inheritance,

members, etc.)

Cohesion

Page 31: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

The Ideal Program (again)

vs.

Page 32: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Finding the structure

Entities Classes Methods Variables

Relationships Inheritance Member Objects Method calls

Page 33: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Approaches

Reverse engineering toolsE.g. Omondo

Reading documentation Reading class names Code reading Talking to people

Page 34: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Also, remember

Existing artifacts, but also Personal experience General knowledge about problem General knowledge about solution

Page 35: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

goals

In terms of our process model

them

Ideas (languages) representations (languages)

you

Ideas (languages)

if(condition) functionCall(X);else functionCall(Y);

goals

knowledge

knowledge

Page 36: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

An example: Jetris

http://jetris.sourceforge.net/

Page 37: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Reverse Engineering Jetris

Multiple “passes”Run the gameReading namesWhat is HTMLLink? PublishHiScore?What is Figures.java? FigureFactory?TetrisGrid (wait, what’s with those arrays?)AddFigure, dropNext, addFigureToGrid…Actual loop? (nextMove)UI

Page 38: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Goals and Knowledge

Of Tetris

Based on other artifacts (running program)

Of tendencies?

Patterns?

Page 39: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Lets get philosophical again!

Page 40: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery in our Models

Feasible Desirable

Conceivable

Outcome Space

Design Space

Page 41: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Product)

Feasible Desirable

Conceivable

Outcome Space

Design Space

Page 42: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Product)

Feasible Desirable

Conceivable

Outcome Space

Design Space

Page 43: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Product)

Feasible Desirable

Conceivable

Outcome Space

Design Space

Page 44: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Not Just the UML

What principles were applied?What were their priorities?What patterns emerged?What actual patterns were used?

What would developers making changes need to consider?

This will save you a lot of trouble

Page 45: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Another (Small) Example

addAllPixels(Image image){

for(int i = 0; i < image.getWidth(); i++){

for(int j = 0; j < image.getHeight(); j++){

Color c = image.getColor(i, j);

addPixel(new Pixel(i, j, c));

addToColumn(i, new Pixel(i, j, c));

updateColorTotals(c);

}}}

Page 46: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

We might be able to guess that:

Need for a pixel class Different instances for

addPixeladdToColumn

Concerned about speedNot so much about space

Concerned about changability?Or just following convention

Page 47: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Could have just been

addAllValues(ImageNumber n){

for(int i = 0; i < image.height; i++){

for(int j = 0; j < image.height; j++){

colorArray[n][i][j] = image.colorAt(i, j);

}}}

Page 48: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

The other side of the coin…

How easy is your program to understand?The dual nature of code

How is your: Documentation Naming Code Metaphor Principles

Page 49: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Finally: What’s Actually Created?

It depends: How difficult? Who else? The future…

Getting philosophical one last time

Page 50: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Process)

activities

Ideas (languages)

activities

Ideas (languages)

representations (languages)

if(condition) functionCall(X);else functionCall(Y);

Page 51: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Process)

activities

Ideas (languages) representations (languages)

activities

Ideas (languages)

representations (languages)

if(condition) functionCall(X);else functionCall(Y);

Page 52: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Design Recovery (Process)

activities

Ideas (languages) representations (languages)

activities

Ideas (languages)

representations (languages)

if(condition) functionCall(X);else functionCall(Y);

goals

knowledge

Page 53: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Finally: What’s Actually Created?

It depends: How difficult? Who else? The future…

We could make UML UI map Program flow Description/Depiction of array metaphors …

Page 54: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Assignment 3 – Design Recovery

Recover the design of PalantírTool for awareness in configuration

management systems developed at UCIYou may use any tools you likeDo not ask anyone about it (despite that

normally being a good resource)

Get the Palantír code from the subversion repository, detailed instructions follow

Page 55: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Assignment 3 – Design Recovery Each group must turn in:

A Complete* UML (-ish) Diagram At least 1 additional diagram of your choice (might be informal) A document describing the design of Palantír (at least 4 pages)

Your audience is someone unfamiliar with Palantír who needs to make very significant changes to it

The code may no longer compile! Your submission graded on completeness, clarity, accuracy

Each person also needs to submit a team evaluation (forms available on class webpage)

Paper copy due Monday, February 9th, at start of class

* see next slide

Page 56: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Assignment 3 – A Caveat on “Complete”

Concentrate on (give complete design of) four packages: edu.isr.palantir edu.isr.palantir.core edu.isr.palantir.server edu.isr.palantir.ui

Other packages and libraries are in the repository! (12) They will be useful references in recovering the design. You must check them out and use them in your analysis. You do not need to fully recover their internal structure. Represent them as amorphous blocks in your UML. Be sure to show, e.g., calls that are made to them, from the four

main packages.

Page 57: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Suggestions for Group Work

Everyone start by taking their own look at the whole systemMultiple perspectives will be very useful

Work out the high level architecture Concentrate on the four main packages Understand program flows Look out for subtle details

Page 58: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Further tips

There are papers available on Palantír on André's website; feel free to consult them

Use representations of classes to organize

Rote completeness is not the answer, will need to be elegant

Page 59: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Team AssignmentsTeam 1 Tomas Ruiz-Lopez Lance Cacho Daniel Morgan Scott Ditch Joshua Villamarzo Derek Lee

Team 2 Alton Chislom Jeffrey Gaskill Matt Fritz James Rose Robert Duncan

Team 3 David Schramm Leslie Liu Chad Curtis Alex Kaiser Ben Kahn

Team 4 Jay Bacuetes Robert Jolly James Milewski Lance Zepeda Aylwin Villanueva

Team 5 Alexander Doan Jordan Sinclair Rakesh Rajput Matt Shigekawa Scott Roeder

Page 60: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions

Two Steps:

1) Install Subclipse plugin for Eclipse

2) Check out the Palantír repository

NB: this assumes that you're using Eclipse and are otherwise comfortable with it.

Page 61: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions1. In Eclipse, go to Help > Software Updates > “Available Software” tab

Page 62: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions2. Hit “add site”, enter location: http://subclipse.tigris.org/update_1.4.x

Page 63: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions3. Hit “OK” => Check the Subclipse main box => hit “Install”

Page 64: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions4. Make sure everything is checked off and hit “Finish”

Page 65: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions5. Let the libraries download => hit “Yes” at this dialogue box

Page 66: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions6. Make a new Project (NOT Java Project) and choose this

Page 67: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions7. Make a new repository location

Page 68: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions8. Enter http://tps.ics.uci.edu/svn/projects/palantir/trunk/ and hit “next”

Page 69: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions9. Select the root of the tree => hit “Next” (NOT “Finish”)

Page 70: Reverse Engineering and Design Recovery Informatics 122 Alex Baker.

Detailed Checkout Instructions10. Check out in the workspace => give it a name => hit “Finish”