Professional Documents
Culture Documents
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.
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
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