P h i

advertisement
Faculty of Information Technology
Department of Software Engineering
Examination Paper
Philadelphia University
Lecturer
: Dr. Ali Fouad
Coordinator
: Dr. Ali Fouad
Internal Examiner : Dr. Samer Hanna
Software Reengineering (721421)
Final Exam
First Semester of 2012-2013
Date: 6-2-2014
Time: 50 minutes
Information for Candidates
1.This examination paper contains six questions, totaling 40 marks.
2.The marks for parts of questions are shown in round brackets.
Advice to Candidates
1. You should attempt all questions.
2. You should write your answers clearly.
I. Basic concepts
Objective: The aim of the question in this part is to evaluate your knowledge and skills concerning with the
basic concepts of software reengineering.
Question 1: (5 marks)
Select for each question the correct answer
1. Changes made to an information system to add the desired but not necessarily the required features is
called
a) Preventative maintenance.
b) Adaptive maintenance.
c) Corrective maintenance.
d) Perfective maintenance.
2. ____slices are computed statically using a dependence graph.
a) Dynamic
b) Static
c) Automatic
d) execution
3. _____ is changing a software system in such a way that it does not alter the external behavior of the code
yet improves its internal structure.
a) Refactoring
b) Translation
c) Adaptive
d) Corrective
4. Modifying the software to match changes in the ever changing environment is called
a) adaptive maintenance
b) corrective maintenance
c) perfective maintenance
d) preventive maintenance
5. Bottom-up code reading strategy:
a) Gives detailed and concrete understanding.
b) Can be difficult to understand full meaning of code without context.
c) Difficult to know where to start in large programs.
d) All of the above
Question 2: (5 marks)
The legacy system is faced with many barriers to change into efficient, reliable and flexible systems.
Give three of these barriers and how can we make legacy system easy to evolve?
II. Familiar Problems Solving
Objectives. The aim of the questions in this part is to evaluate that the student has some basic
knowledge of the key aspects of the lecture material and can attempt to solve familiar problems.
Question 3: (5 marks)
Translate the following if Clause with a goto (or spaghetti code) into its structured equivalent.
if ( StatusOK ) {
if ( DataAvail )
{
ImportantVar = x;
goto MID_LOOP;
}
}else {
ImportantVar = GetVal();
MID_LOOP: DoLotsOfCode( ImportantVar );
}
Question 4: (5 marks)
Find static Slice for the following code with respect to <23, mn>:
main() {
1. int mx, mn, av;
2. int tmp, sum, num;
3.
4. tmp = readInt():
5. mx = tmp;
6. mn = tmp;
7. sum = tmp;
8. num = 1;
9.
10. while(tmp >= 0)
11. {
12. if (mx < tmp)
13. mx = tmp;
14. if (mn > tmp)
15. mn = tmp;
16. sum += tmp;
17. ++num;
18. tmp = readInt();
19. }
20.
21. av = sum / num;
22. printf(“\nMax=%d”, mx);
23. printf(“\nMin=%d”, mn);
24. printf(“\nAvg=%d”, av);
}
Question 4: (10 marks)
Draw Flow Dependency Graph and Control Dependency Graph for the following piece of code:
Public void Calc ( n ){
i=1;
prod = 1 ;
sum = 0 ;
while ( i<=n ){
sum = sum + 1 ;
prod = prod * i ;
i ++;
}
print ( sum ) ;
print (prod ) ;
}
Question 5: (5 marks)
Assume you have the Control Flow Graph for a program shown at
right side:
1. Node A is post dominated by ___
2. Node C is post dominated by ___
3. is true that all nodes are post dominated by node B?
4. Find control dependency graph by filling blanks by a suitable node.
a. B is control dependent on ___ and ____
b. C are control dependent on ___ and ___
III. Unfamiliar Problems Solving
Objectives. The aim of the questions in this part is to evaluate that the student can solve familiar
problems with ease and can make progress towards the solution of unfamiliar problems, and can set
out reasoning and explanation in a clear and coherent manner.
Question 6: (5 marks)
Name and locate all the things are bad smells with the following code, Give the reasons and refactor
type of all these locations.
public class HourlyWorker {
private String name;
public String workTitle;
public decimal rate;
private int hours;
public decimal Earning()
{
return rate*hours; }
-}
public class SalaryWorker{
private String name;
public String workTitle;
private decimal salay;
public decimal Earning()
{…..
// compute Additional work to salary
totalsalary =salay + rate*hours;
….
}
}
Download