Semi-Automated Software Restructuring - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Semi-Automated Software Restructuring

Description:

Connection is sought with existing types of assessment such as EIA and SEA. ... Recreation. Access to care and care utilisation. or... Pilots: The tool was tested in: ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 36
Provided by: broe8
Category:

less

Transcript and Presenter's Notes

Title: Semi-Automated Software Restructuring


1
Semi-Automated Software Restructuring
  • By Santosh K Singh Kesar
  • Advisor
  • Dr. James Fawcett

Masters Thesis Dept. of Electrical Engineering
and Computer Science, Syracuse
University October 8, 2008
2
Long-Term Research Goals
  • Attempt to answer the question
  • Is it possible to reliably improve the structure
    of large, complex, software?
  • If so, can that be automated?
  • If so, find appropriate means to implement a
    process for such improvement.

3
Specific Goals of this Research
  • Find ways to reduce the size of large functions
    and methods by turning them into a composition of
    smaller functions and methods with the same
    behavior.
  • Automate that process.
  • Evaluate the results.

4
Software Restructuring
  • Extracting new functions and methods from source
    code functions and methods.
  • Semi-Automated Source Code Restructuring
  • Maintains the same external behavior of
    restructured source code.
  • New files of restructured source code written, in
    a different location from actual source code

5
Restructuring v/s Refactoring
  • Both code restructuring and refactoring are
    concerned with improving logical structure.
  • Refactoring is a largely manual process with
    broader scope.
  • Restructuring is automatic, but user-guided.
  • Refactoring has traditionally been applied to
    managed source code
  • Java in Eclipse
  • C in Visual Studio
  • Our restructuring works with native languages C
    and C

6
Is Badly Structured Code Likely?
  • Is there a need for the results of this research?
  • Do experienced researchers and professional
    developers often create badly structured code?

7
Imaging Research Code
File Function Name Number of lines
Weights_calculation.cpp WeightTwoQuadrantsFactor 280
Weights_calculation.cpp FactorsTwoRays 206
Weights_calculation.cpp AreaWeightFactor 223
Weights_calculation.cpp W_Calculate 377
Weights_calculation.cpp Main 191
Weights_calculation.cpp WeightBottomFactor 164
Mlr800fs.c Emsid2_new 724
Mlr800fs.c Main 851
Mlr800fs.c Ect 3608
Mlr800fs.c emsid3_new 749
Mlr800fs.c emsid4 516
8
GKGFX Library, Mozilla 1.4.1
Smallest disk is a file
Dependency Lines
Number indicates the size of a strong component,
in this case, 60 mutually dependent files
9
Restructuring Process
  • Analysis
  • Find feasible regions for function extraction
  • Selection
  • Select from feasible regions code segments that
    require few parameters to be passed as function
    arguments
  • Code generation

10
Analysis
  • Lexical analysis
  • Tokenize input stream
  • Group into analysis sequences
  • Parsing
  • Recognize key grammatical elements
  • Store for later use
  • Deeper analysis of functions

11
Lexical Analysis
  • Tokenize
  • Remove comments
  • Eliminate whitespace
  • Recognize key punctuators
  • Form semi-expressions
  • Sequences of tokens appropriate for parsing

12
Our Lexical Analysis Tools
  • Tokenizer

Sample output from Tokenizer Module
13
Our Lexical Analysis Tools
  • Semi-Expressions

Sample output from Semi-Expressions Module
14
Parsing
  • Recognize key grammatical elements
  • A very small subset of language grammar
  • Function definitions
  • Method definitions
  • Data declarations
  • Data manipulations
  • Build parse tree
  • Use tree elements to support code generation

15
Parse Tree
Top Level Structure of Parse Tree
16
Types of Nodes
Different types of Nodes in Parse Tree
17
Building Parse Tree
Building of First Three Levels
18
Containment Diagram of Parse Tree
Top Level Containment diagram of Parse Tree
19
Criteria 1 Line Numbers
Line number criteria for Feasible Regions
20
Top down approach
Top down approach for determining parameters
21
Class Diagram of Parsers
Class Diagram of Parsers using Utility Class
22
Class Diagram of ICRNode
Class Diagram of ICRNode Interface
23
Class Diagram of RootObj
Class Diagram of RootObj
24
Association of DataObjects
Class Relationship diagram of Parse tree Objects
25
Representing Node Types
Class Diagram of Different Node Types
26
Class Diagram of DataObject
Class Diagram of DataObject
27
Hierarchy Stack
Stack Top Pointer
Hypothetical view of Hierarchy Stack
28
Class Diagram of TempContainer
Figure 3.16 Class Diagram of TempContainer
29
Class Diagram feasibleRegions and newFunctions
Class Relationship diagram of feasibleRegions and
newFunctions
30
Class Diagram FunctionParser and fileManager
Class Relationship diagram of FunctionParser and
fileManager
31
Restructuring in multiple passes
Original length of testFun function 120
32
Restructuring Functions
void setRootValues() try
stdstring inFile getInputFile()
Directory dir Scanner scanr
scanr.doRecursiveScan(inFile)
dir.RestoreFirstDirectory()
if(dir.dirContainIncludes())
scanr.setFileIncludes() stdvectorltstdst
ringgt _files getCompleteFiles()
if(_files.size() gt 0) RootObj
root new RootObj() stdstring _type
root-gt_typename() if(_type "")
_type "pRoot"
root-gtdisplayRootStats()
catch(stdexception ex) stdcoutltlt
ex.what() ltltstdendl
Original Source code
33
Extracted Function
Restructured Code
void setRootValues_1() stdstring inFile
getInputFile() Directory dir Scanner
scanr scanr.doRecursiveScan(inFile)
dir.RestoreFirstDirectory()
if(dir.dirContainIncludes())
scanr.setFileIncludes()
void setRootValues() try
setRootValues_1() stdvectorltstdstringgt
_files getCompleteFiles()
if(_files.size() gt 0) RootObj
root new RootObj() stdstring _type
root-gt_typename() if(_type "")
_type "pRoot"
root-gtdisplayRootStats()
catch(stdexception ex) stdcoutltlt
ex.what() ltltstdendl
34
Contributions
  • Semi-Automated Software Restructuring
  • Type Analysis parser for host language
  • Representing source code structure as Parse tree
  • Identification of Feasible regions
  • Demonstration with working code
  • Future Work
  • Further Optimization can be achieved.
  • Semantic cues may help make sensible functions.
  • Other things to think about like extracting
    Objects.

35
Changes to Thesis document
  • Removed references to SMIRG
  • Re-formatted to match university regulations.

36
Demonstration
  • Simple code that shows
  • Parsing Functions and Methods
  • Manages header and implementation files correctly.

37
End of Presentation
  • Questions ?
Write a Comment
User Comments (0)
About PowerShow.com