Академический Документы
Профессиональный Документы
Культура Документы
Reverse Engineering
Code Restructuring Mainframe
Guest Lecture
Exercises
October 2007 – 3rd Version
presented by
Dipl. Ing. Werner Hoffmann
A member of IEEE and ACM
1. Basic Methods
2. Restructuring
3. Some more complex examples
• Basic Methods
• Restructuring
• Some more complex examples
A) Name the method(s) which are used for source code restructuring in
the following example. Additional name the resulting structural control
blocks.
___________________
F
T
1 F1 p1 ?
3 = 3
F2
T
F
2 p2 ?
Method:
___________________
_____________________________
B) Name the method(s) which are used for source code restructuring in
the following example. Name additional methods to get structural
control blocks.
__________________________
J
__________________________ T
1 F
1
1 J 1 K p1
__________________________
K 3 4
K J
T T
2 F F
2 p1 3 = 2
2 p1 L
L
_____________________________
____________________________
Method:
C) Name the method(s) which are used for source code restructuring in
the following example.
H H
1 2 H = H 1 2
H
Method:
____________________________
D) Name the method(s) which are used for source code restructuring in
the following example. Name additional methods to get basic structural
control blocks.
G
__________________________
F F,G,E
E
T T
F F
1 I p1 H = 1 I p1 H
____________________________
Method:
E) Name the method(s) which are used for source code restructuring in
the following example.
B
B 1 A
1
C 2 = C 2 3
D 3 D
Method: ____________________________
F) Name the method(s) which are used for source code restructuring in
the following example. Means:______________________
A A
F T
T F
1 p = 1 ¬p
T F
F T
1 A q = 1 A ¬q
Means:______________________
Method: ____________________________
• Basic Methods
• Restructuring
• Some more complex examples
A
T
F
1 B p
A
T
q
F
T
p 2
1 B
T
T
p 2 q
F
F
1 B
F3
T
T F
1 F1 2 p1 p2
F2
• Basic Methods
• Restructuring
• Some more complex
examples
A) Specification:
A) Pseudo-Code:
L1 = 55000 *loan 1 Paid_Off:
I1 = 0.006 *interest 1 Print m ‘left=‘ p-L2
L2 = 26000 *loan 2 EXIT
I2 = 0.009 *interest 2 Low_Payment:
Pay = 1500 *monthly payment Print ‘payment < interest’
M = 0 *month number EXIT
Next_Month:
M = M + 1
p = Pay – (L1*I1) – (L2*I2)
IF p <= 0 goto Low_Payment
IF L1 <= 0 goto Mortgate2
IF p <= L1
THEN L1 = L1 – p; p = 0
ELSE p = p – L1; L1 = 0
IF p <= 0 goto Next_Month
Mortage2:
if p >= L2 goto Paid_Off
L2 = L2 – p
goto Next_Month
Date: 21.06.2007 Code Restructuring - Exercises Page: 17
Exercise: Example 2 (1)
Code Restructuring
I tha
n
for y k you
o
atte ur
ntio
n!