Notes 002

advertisement
SE 386 Software Maintenance and Reengineering
Notes 002 – Structured Analysis
1 Structured Analysis
Often we are given a system with little or untrustworthy documentation. Sometimes this code is old and
may not be OO-based. One way to gain an understanding of this type of system is to perform Structured
Analysis and generate a data dictionary of the code.
Structured analysis and a data dictionary are static representations of the code that can help us gain
initial understanding of a software system.
 Structured Analysis helps one determine which functions call which other functions and what
data are passed.
 A Data dictionary helps us keep track of data identifiers and how and where they are used.
2 Data Dictionary
Data dictionary is a repository of information about the data in a system.

It is usually alphabetical so that we can easily lookup information about the usage of the
constants, variables and structures.

Items may have a secondary key that help us look up an identifier in other ways other than name,
such as by function or by logical relationships.

A Data Diction may contains:

A description of the data

A formal definition of the data, which may include:
o Data type (and size for strings, arrays, structures, etc.)
o Initial and/or default value
o Range of values
o Valid values
o Logical relationships between this and other fields if there are any.
o Function(s) that uses data.
o Cross references to other variable ids that related (like formal parameter of other
functions),
o A data dictionary can be the start of a database schema.
© 2012 Mike Rowe
Page 1
2/9/2016 11:26:00 AM
SE 386 Software Maintenance and Reengineering
Notes 002 – Structured Analysis
Data
id
Description
Type Initial Range
value
score
A test score
float
N/a
sum
Sum of
scores
Float
0.0
Logical
Function
Cross Reference
(0,100) N/a
processOneSection
Max( num1)
GE 0.0 The more
scores and
higher the
scores the
larger sum
will be
main
processOneSection
relationships
processClassTotals
3 Structure Diagrams
Structure Diagrams can be used to understand or reverse engineer existing systems.
 In a structure chart we connect calling functions with called function with arcs. The arcs exit
the bottom of the calling function and enter the top of the called function.
 The Called function is usually below the calling function. That would mean that the main( )
function would be at the top of the page.
 An arc represents a parameter that is exchanged between the calling and called function.
There is an arc for each parameter passed, although sometimes, when there are many related
parameters one arc is used. Use the parameter id of the called function, for instance “num1”
instead of “score” in the call of function max() from processOneSection().
 Each arc has arrows indicating its parameter’s usage (IN, OUT, or INOUT).
o An arc with an arrow ONLY pointing into the called function would be an IN parameter.
o An arc with an arrow ONLY pointing into the calling function would be an OUT
parameter.
o INOUT parameters would have arrows point into both the calling and called functions. .
 Functions that return a value have an arc with a right angle going out of their side. See function
max().
 A comment is commonly added to functions regarding the purpose of a function or any
processing constraints.
 Several solution for functions that are highly coupled.
C++ example:
The main() is at the top – level 0.
Functions that are directly called from the main() are connected – level 1, and the parameters are used to
define connecting arcs.
This process continues by add functions that are called by the level 1functions to create level 2.
© 2012 Mike Rowe
Page 2
2/9/2016 11:26:00 AM
SE 386 Software Maintenance and Reengineering
Notes 002 – Structured Analysis
...
//------- main () -----------------------------------------------int main()
{
float sum, sumAll = 0.0;
int sections = 1; // section number being processed
int count, countAll = 0;
// count of students
//------------------------------------// PRIMING READ FOR eof LOOP
cin >> count; // how many scores in a section
while ( ! cin.eof() )
// loop till eof
{
//---------------------------------// PROCESS ONE SECTION OF GRADES
processOneSection( sum, sections, count );
//---------------------------------// ACCUMULATE CLASS SUM AND COUNT
processClassTotals( sumAll, countAll, sum, count );
cin >> count;
sections++;
} //------ END WHILE -- END OF CLASS-----------------displayClassResults( sections, countAll, sumAll );
cout << endl << "That's all the sections!! Normal Termination.";
return 0;
}
//-------end of main()-----------------------------------//-----------------------------------------------------------------// Function to process a section's worth of data
// PARAMS (
OUT,
IN,
IN
)
void processOneSection( float & sum, int sections, int count )
{
int a_count, b_count, c_count, d_count, f_count, loopEnd;
float score, hi_score, lo_score;
cout << "Scores for section " << sections << endl;
//--------------------------------------------// INTIALIZE SECTION ACCUMULATORS AND COUNTERS
initSection( a_count, b_count, c_count, d_count, f_count,
loopEnd, sum, hi_score, lo_score );
while ( loopEnd < count ) // loop to read section scores
{
cin >> score;
//-------------------------------// COUNT A's, B's, etc.
determineGrade( score, a_count, b_count, c_count, d_count, f_count );
//--------------------------------// FIND HIGHEST AND LOWEST SCORES
hi_score = max ( score, hi_score );
min ( lo_score, score );
//----------------------------------// SECTION SUM OF SCORES FOR AVERAGE
// to compute the average
sum += score;
loopEnd++; // COUNT CONTROL LOOP UPDATE
}//------ END WHILE -- SECTION END -------//--------------------------------// DISPLAY THIS SECTION'S RESULTS
displaySectionResults( a_count, b_count, c_count, d_count, f_count,
count, sum, hi_score, lo_score );
} //--------END OF processOneSection( ) ----------------------------//-------------------------------------------------------------------
© 2012 Mike Rowe
Page 3
2/9/2016 11:26:00 AM
SE 386 Software Maintenance and Reengineering
Notes 002 – Structured Analysis
// function to return the larger of two numbers
// PARAMS (
IN,
IN
)
float max( float num1, float num2 )
{
if ( num1 < num2 )
return num2;
else
return num1;
} //--------------END OF max( )--------------------------------------
main( )
sections,
count
sum
processOneSection( )
//reads and processed one sections
worth of grades.
mn
num
num1,
num2
max()
min( )
We have a Visio available through the Microsoft Academic Alliance licensing arrangement. For this class I
would like to standardize on Visio. You can install on your own computers.
3.1 Understand for C++
Understand for C++ is a reverse engineering, documentation and metrics tool for C and C++ source
code. It offers code navigation using a detailed cross reference, a syntax colorizing "smart" editor, and a
variety of graphical reverse engineering views. Understand for C++ is an interactive development
environment (IDE) designed to help maintain and understand large amounts of legacy or newly created
C and C++ source code. Check our features page for a listing of Understand for C++ features. See
http://www.scitools.com/
© 2012 Mike Rowe
Page 4
2/9/2016 11:26:00 AM
Download