You are on page 1of 4

Cairo University Faculty of Computers and Artificial Intelligence

Computer Science Department


CS 352: Advanced Software Engineering, MIDTERM EXAMINATION
Instructor: Dr. Soha Makady
Fall 2020 – CLOSED Book Exam –Total marks: 20 – Duration: 60 mins
This exam comes in four pages

Student Name _________________________________

Student ID __________________________ Group No. ________________________

Note: Some questions demand explanations and/or justification. If no explanation and/or


justification is provided, that question will receive a zero grade.

Question 1 [4 marks]
a) Among the object-oriented principles discussed in the course, was “Code to an interface rather
than to an implementation”. Give an example to illustrate that principle. Your example needs to
show how you code to an implementation versus how you code to an interface [2].

b) During the lectures, we discussed two possible classifications for design patterns. Consider the
strategy pattern. Classify this pattern two times: one time according to the first classification,
and one time according to the second classification. For each classification, justify why you
made that classification. [2]

Page 1 of 4
Question 2 [10 marks]
During the lectures, we discussed the SOLID principles. For each of the following designs:
(i) identify the violated SOLID principle, (ii) explain how it was violated, and (iii) modify that
design (and source code if needed) to abide by the identified SOLID principle. Make and state any
needed assumptions that would help you answer this question.

a) [4 marks] Consider an application that draws shapes (e.g., circles, rectangles) on a standard
GUI. The following design is provided for shapes.

Drawing is implemented in a separate method within an Application class as follows:


public class Application {
public void drawAllShapes(List<Shape> shapes) {
for(Shape shape : shapes) {
switch(shape.getType()) {
case Circle:
drawCircle((Circle)shape);
break;
case Rectangle:
drawRectangle((Rectangle)shape);
break;
}
}
}
private void drawCircle(Circle circle) {...}
private void drawRectangle(Rectangle rectangle) {...}
}

Page 2 of 4
b) [3 marks] Consider the following text manipulator (‫ )معالج النص‬class.

TextManipulator

String text

+getText(): String
+appendText(): void
+findWordAndReplace(…): String
+findWordAndDelete(…): String
+printText(): void
+printRangeOfCharacters(…): void

c) [3 marks] Consider an application for modeling GUI elements (like popup windows, message
boxes, …etc.) with the below design.
Square

double length

+Area (): double

PopUpWindow

Page 3 of 4
Question 3 [6 marks]
Consider a Software company that can have departments. Such departments can have
employees. Those employees might/might not be managing other employees within sub
departments. The software company would like to show the details of all the employees within any
specific department along with its sub departments (if any). Furthermore, while signing their
employment contracts, employees get to choose their preferred payment choice. There are three
payment choices (to get paid by a bank transfer, to get paid using a cheque (‫)شيك بنكي‬, or to get paid
using cash money). Employees can change their initial payment choice while the payment
application is running. Sketch one class diagram to model that company after applying the needed
design pattern(s). The diagram should clearly show the attributes/operations/relationships as
needed. Justify why you selected each pattern(s).

End of Exam

Page 4 of 4

You might also like