Chapter 5 - University of Wisconsin

advertisement
Chapter 5:
Software
Re-Engineering
Omar Meqdadi
SE 3860 Lecture 5
Department of Computer Science and Software Engineering
University of Wisconsin-Platteville
Topic Covered

Software Re-engineering
Life-Cycle of Software Re-engineering
Reverse Engineering

Software Re-engineering Process


2
Definitions


Forward Engineering is the traditional process of moving
from high-level abstractions and logical, implementationindependent 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 a
higher level of abstraction.
3
Definitions

Reengineering - Reorganising and modifying existing
software systems to make them more maintainable by
first reverse engineering and then forward engineering

Refactoring - A program restructuring (rearranging) in a
series of small, semantics preserving transformations in
order to make the code easier to maintain and modify
4
Forward Engineering and Reverse
Engineering
Forward Engineering
Reverse Engineering
Requirements
Analysis
Design
Implementation
Forward Engineering and ReEngineering
6
System Re-engineering




A Preventive Maintenance activity
Re-structuring or re-writing part or all of a legacy system
without changing its functionality
Applicable where some but not all sub-systems of a larger
system require frequent maintenance
Re-engineering involves adding effort to make them
easier to maintain. The system may be re-structured and
re-documented.
7
When to Re-engineer?

Port to other Platform
 when

Design extraction
 to

hardware or software support becomes obsolete
improve maintainability, portability, etc.
Exploitation of New Technology
 new
language features, standards, libraries, etc.
 when tools to support restructuring are readily available
8
Re-engineering Advantages

Reduced risk
 There
is a high risk in new software development. There
may be development problems, staffing problems and
specification problems

Reduced cost
 The
cost of re-engineering is often significantly less than
the costs of developing new software
9
Re-engineering Cost Factors




The quality of the software to be re-engineered
The tool support available for re-engineering
The extent of the data conversion which is required
The availability of expert staff for re-engineering
10
Re-engineering Cost
11
Life-Cycle of Re-engineering
(1) requirement
analysis
Requirements
(3) problem
detection
(4) problem
resolution
Designs
(2) model
capture
• people centric
• lightweight
Code
(5) program transformation
Life-Cycle of Re-engineering

Reverse Engineering Phase

Requirement analysis: analyze on which parts of your
requirements have changed
 Model capture: reverse engineer from the source-code into a
more abstract form, typically some form of a design model

Forwarded Engineering Phase

Problem detection: identify design problems in that abstract
model
 Problem resolution: propose an alternative design that will
solve the identified problem
 Program transformations: make the necessary changes to the
code, so that it adheres to the new design yet preserves all the
required functionality
Re-engineering Process Activities

Source code translation


Reverse engineering



Restructure automatically for understandability
Design recovery and reimplementation
Program modularization


Analyze the program to understand it
Program structure improvement


Convert code to a new language
Reorganize the program structure
Data reengineering

Clean-up and restructure system data
14
Source Code Translation


Involves converting the code from one language (or
language version) to another e.g. FORTRAN to C
May be necessary because of:
 Hardware
platform update
 Staff skill shortages
 Organisational policy changes

Only realistic if an automatic translator is available
15
Source Code Translation
16
Reverse Engineering

Program Comprehension
 Analysing
existing software with a view to understand its
design and specification
 Systematic process of acquiring important design factors
and information regarding engineering aspects from an
existing product
 A process which analyses a product/technology to find out
the design aspects and its functions

Builds a program data base and generates information
from this
17
Reverse Engineering Goals

Cope with complexity
 need

techniques to understand large, complex systems
Recover lost information
 extract what

Detect side effects
 help

changes have been made and why
understand ramifications of changes
Synthesize higher abstractions
 identify latent abstractions in

software
Facilitate reuse
 detect candidate reusable artifacts and
components
18
Reverse Engineering Activities

Understanding process
 source
code is analyzed to at varying levels of detail
 to understand procedural abstractions and overall
functionality

Understanding data
 internal data
structures
 database structure

Understanding user interfaces
 what
are basic actions processed by the interface?
 what is system's behavioral response to these actions?
19
Reverse Engineering Process
20
Reverse Engineering Techniques

Re-documentation
 pretty
printers
 diagram generators
 cross-reference listing generators

Design recovery
 software
metrics
 browsers
 visualization tools
 static analyzers
 dynamic
(trace) analyzers
21
Reverse Engineering for Software
Maintenance

Corrective maintenance:
 Easier
to identify defective program components and the
source of residual errors

Adaptive/Perfective maintenance:
 Eases
understanding of system’s components and their
interrelationships, showing where new requirements fit and
how they relate to existing components

Preventive Maintenance
 Represent
the first phase of the re-engineering process
22
Code Restructuring (Refactoring)


Maintenance tends to corrupt the structure of a program.
It becomes harder and harder to understand
So, the program may be automatically restructured
 Source
code is analyzed and violations of structured
programming practices are noted and repaired
 Examples:


Remove unconditional branches
Conditions may be simplified to make them more readable
 Revised
code needs to be reviewed and tested
23
Code Restructuring (Refactoring)

Example1: Spaghetti logic
24
Code Restructuring (Refactoring)

Example1: Structured control logic
25
Code Restructuring (Refactoring)

Example2: Condition simplification
-- Complex condition
if not (A > B and (C < D or not ( E > F) ) )...
-- Simplified condition
if (A <= B and (C>= D or E > F)...
26
Program Modularization


The process of re-organising a program so that related
program parts are collected together in a single module
Usually a manual process that is carried out by program
inspection and re-organisation
27
Module Types

Data abstractions
 Abstract
data types where data structures and associated
operations are grouped

Hardware modules
 All

functions required to interface with a hardware unit
Functional modules
 Modules
containing functions that carry out closely related
tasks

Process support modules
 Modules
where the functions support a business process or
process fragment
28
Data Re-Engineering






Involves analysing and reorganising the data structures
(and sometimes the data values) in a program
Existing data structures are reviewed for quality
Integrating and centralizing multiple databases
Unifying multiple, inconsistent representations
Upgrading data models
Objective is to create a managed data environment
29
Data Problems




End-users want data on their desktop machines rather
than in a file system.
Systems may have to process much more data than was
originally intended by their designers
Redundant data may be stored in different formats in
different places in the system
Data naming problems
 Names
may be hard to understand. The same data may
have different names in different programs
30
Data Problems

Field length problems
 The
same item may be assigned different lengths in
different programs

Record organisation problems
 Records
representing the same entity may be organised
differently in different programs


Hard-coded literals
No data dictionary
31
Data Re-engineering Approaches
32
Data Re-engineering Process
33
Data Conversion


Changing the data structure organisation without
changing the data values
Data value conversion is very expensive. Special-purpose
programs have to be written to carry out the conversion
34
Download