Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

________________________________________________________

SCHOOL OF ENGINEERING AND TECHNOLOGY

EXAMINATION FOR THE BACHELOR OF SOFTWARE ENGINEERING (HONS);


YEAR 3

ACADEMIC SESSION 2022; SEMESTER 6, 7

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE

FINAL – JULY 2022 EXAM CYCLE

TIME: 2 HOURS AND 10 MINUTES READING TIME


_______________________________________________________

INSTRUCTIONS TO CANDIDATES

This exam contains FIVE questions.

Answer ALL questions.

IMPORTANT NOTES TO CANDIDATES

This is an open-book online exam. It is your responsibility to ensure that you only depend on the
materials taught in the classes and other references you may find helpful. Consulting external
people or other colleagues is not allowed.
Question 1 (15 marks)

In mobile e-hailing applications such as Grab, users use the system often to book several types
of transportation means (e.g. budget cars). Users can check the fare before confirming their
booking. Once a booking is confirmed, the passenger can see the driver name and the car’s
real-time location on the map. Also, they can pay the fare using several means (e.g. online
payment).

Assume you are a maintenance engineer in a team that is responsible for maintaining the
application in the following scenario:

The scenario: “An issue has been discovered in the system makes it possible for users
to access the system in unwanted ways (e.g. modify the fares). As a maintenance
engineer, you are asked to maintain the system as fast as possible so that the users cannot
change the decided fares. Given that this issue has been resolved, several complaints
have been later sent to the maintenance team that the actual driver location is not shown
instantly to the passenger so that there is some latency. As a maintenance engineer, you
are also required to resolve this problem.”

a) For every required maintenance activity in the scenario and based on the decision tree-
based criteria in Figure 1:

i. Identify the cluster to be maintained via answering the related questions. [4 marks]
ii. Identify evidence maintenance type via answering the related questions. [4 marks]

-Figure 1-

b) Propose another scenario in which a change request is sent by one stakeholder to address
an issue in the system and accordingly a maintenance activity is required. Decide what
maintenance type is required based on the decision tree-based criteria in Figure 1 by
answering the related questions with justification. [4 marks]

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE (JULY 2022) 1


c) SPE (Specified, Problem, Evolving) classification scheme/taxonomy is to explain the ways
in which programs vary in their evolutionary characteristics.

According to SPE taxonomy, select the type of the tackled e-hailing application in the
above-mentioned scenario. Justify your answer in detail. [3 marks]

Question 2 (5 marks)

There are many kinds of maintenance activities in evidence-based classification of Software


Maintenance. The impacts of the different types on software and business vary according to
the activity. Based on that, select the right answer of these questions and justify your choice by
identifying the maintenance type of every maintenance activity:
(1 mark for every question)

1- Which of these maintenance activities has the most impact on software?


a. Fixing a bug
b. Add a new feature/functionality
c. Updating documents

2- Which of these maintenance activities has the most impact on business?


a. Enhance the security of a software
b. Fixing a bug
c. Updating documents

3- Which of these maintenance activities has the least impact on software?


a. Enhance the maintainability of a software
b. Updating documents
c. Add a new feature/functionality

4- Which of these maintenance activities has the most impact on software?


a. Enhance the security of a software
b. Fixing a bug
c. Teach customers to prepare maintenance requests

5- Which of these maintenance activities has the most impact on business?


a. Fixing a bug
b. Add a new feature/functionality
c. Updating documents

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE (JULY 2022) 2


Question 3 (15 marks)

Program slicing is a technique for reverse engineering.


a) Present a scenario in which program slicing proves useful. [1 mark]
b) Explain the difference between static and dynamic slicing using the same scenario
presented in a). [1 mark]
c) Consider the following program in Figure 2 for a movie management system that
manages the number of movies and users’ ratings considering different movies’
categories. The program calculates and prints the average rating for a specific category
if it is less than the movies’ average rating.
• Draw the control flow graph CFG [2 marks]
• Obtain the backward slice for the variable AverageAdMRating at the point at which
it is printed out in the line 48. Explain how the slice is obtained using and the
program dependence graph PDG considering the data and control dependencies
that are required to obtain the slice and that are among the statements of the slice.
[11 marks]

1. import java.util.ArrayList;
2. import java.util.Scanner;
3. public class MovieManagementSystem {
4. public static void main(String[] args) {
5. ArrayList<String> MovieTitles = new ArrayList<String>();
6. String newMovietitle;
7. int MCount = 0; // the number of movies in the system
8. int AcMCount = 0 ; // number of action movies in the system
9. int AdMoviesCount = 0 ; // number of adventure movies in the system
10. double TotalRating=0; // The total sum of all ratings of all movies
11. double TotalAcMRating=0;// The total sum of all ratings of action movies
12. double TotalAdMRating=0;// The total sum of all ratings of adventure movies
13. double AverageRating=0;// The average rating of all movies
14. double AverageAcMRating = 0; // The average rating of action movies
15. double AverageAdMRating = 0; // The average rating of adventure movies
16. Scanner input = new Scanner(System.in);
17. System.out.print("Enter a new movie title: ");
18. newMovietitle = input.next();
19. while (!(newMovietitle.equals("end"))) {
20. MovieTitles.add(newMovietitle);
21. MCount = MCount + 1;
22. System.out.print("Enter the movie rating: ");
23. double mrating= input.nextDouble();
24. System.out.print("What is the movie type: (Action/Adventure)");
25. String mtype= input.next();
26. if (mtype.equalsIgnoreCase("Action"))
27. {
28. AcMCount += 1 ;
29. TotalAcMRating += mrating;
30. }
31. if (mtype.equalsIgnoreCase("Adventure"))
32. {
33. AdMoviesCount += 1 ;
34. TotalAdMRating += mrating;
35. }
36. TotalRating += mrating ;

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE (JULY 2022) 3


37. System.out.print("Enter a new movie title: ");
38. newMovietitle = input.next();
39. }
40. AverageAcMRating = TotalAcMRating/AcMCount;
41. AverageAdMRating = TotalAdMRating/AdMoviesCount;
42. AverageRating = TotalRating/MCount;
43. System.out.printf("There are %d movies, %d Action movies and %d Adventure
movies\n",MCount, AcMCount, AdMoviesCount) ;
44. System.out.printf("The movies' average rating is %f\n",AverageRating) ;
45. if (AverageAcMRating < AverageRating)
46. System.out.printf("The average rating of action movies is %f and it is below
than the general average rating\n",AverageAcMRating) ;
47. if (AverageAdMRating < AverageRating)
48. System.out.printf("The average rating of adventure movies is %f and it is
below than the general average rating\n",AverageAdMRating) ;
49. }
50.}
-Figure 2-

Question 4 (9 marks)

Consider the following program in Figure 3.

1. public class Main {


2.
3. public int add(int a, int b) {
4. int sum = a + b;
5. return sum;
6. }
7.
8. public int sub(int a, int b) {
9. int sub = a - b;
10. return sub;
11. }
12.
13. public void square(int num) {
14. int result = num * num;
15. System.out.println(result);
16. }
17.
18. public static void main(String[] args) {
19. Main obj = new Main();
20. obj.square(obj.add(3, 2));
21. System.out.println(obj.sub(5, 2));
22. }
23. }

-Figure 3-

a) Draw the call graph of this program. [6 marks]


b) Explain the edges of the call graph. [3 marks]

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE (JULY 2022) 4


Question 5 (6 marks)

Consider that following java code, shown in Figure4, for a learning management system
requires some refactoring effort to improve its quality.

1. import java.util.Scanner;
2. public class LearningManagementSystem {
3. public static void main(String[] args) {
4. String studentName;
5. System.out.println("Enter a student name to be enrolled");
6. Scanner input = new Scanner(System.in);
7. studentName = input.next();
8. while (!(studentName.equals("end"))) {
9. Student stdObj = new Student(studentName);
10. System.out.print("Enter a student name to be enrolled");
11. studentName = input.next();
12. }
13. System.out.println("The Enrolled students are ");
14. for(Object studentObj: Student.getInstances()){
15. System.out.println("The student "+((Student)studentObj).studentName+"
"+ "is enrolled");
16. }
17. }
18. }

1. import java.util.ArrayList;
2. public class Student {
3. public String studentName;
4. private static ArrayList instances = new ArrayList();
5. public Student(String name){
6. this.studentName = name;
7. instances.add(this);
8. }
9. public static ArrayList getInstances() {
10. return instances;
11. }
12. }

-Figure 4-

Propose two refactorings on the code as follows. For every required refactoring, show the
code to be added and modified and explain the benefit of doing the refactoring.

a) Employ the extract method refactoring to extract a method for listing the enrolled
students and to use it in the code; (the extracted method shall perform the same
functionality performed by the lines of code 13-16 in the class
LearningManagementSystem). [3 marks]
b) Employ the concept of Encapsulate Field to encapsulate studentName. [3 marks]

~ END OF PAPER ~

SWE3053: SOFTWARE EVOLUTION AND MAINTENANCE (JULY 2022) 5

You might also like