Upload a single PDF file with your answers to the following questions. The file should be named: lastName_firstName_ID_A3.pdf
You can submit multiple times, only the last submission is considered.
This assignment should be completed individually.
Question 1 [5 marks]
Using the example of the Trip Planning Software discussed in class (see sec 6.4.1 in the textbook), suppose that the PlanningService class needs to sort trips
using one of the following algorithms: bubble sort, heap sort, or quick sort. The selection of an algorithm will depend on the context in which the collection of trips is used: sometimes a bubble sort should be used, sometimes a heap sort,etc.
- Which design pattern would you use to allow for the selection of any of these sorting algorithms at run time, and for the possibility of adding new such algorithms in future releases?
- Once you have selected an appropriate design pattern, justify your choice by listing the needs of the problem that correspond to the intent of the pattern.
- Show in a class diagram how the use of the pattern would look like.
Question 2 [5 marks]
You are creating an application that needs functionality for logging. You need to implement a logger and the log information (logging of actions, user who performs the action, and time of action) into a file. Log requests will come from different sources and need to be written to the file.
- Which design pattern will allow you to handle this situation? B. Once you have selected an appropriate design pattern, justify your choice by showing what needs of the problem correspond to the intent of the pattern.
- Illustrate in a class diagram what the use of the pattern would look like.
Question 3 [5 marks]
The class diagram below illustrates a problematic situation where client classes have too many relationships with subsystem’s classes.
Question 4 [5 marks]
Suppose you’re developing a genealogy system, in which you have to model various human relationships. The class diagram below is from this system. Notes:
– A person may have multiple marriages, and also children with several different partners over the course of his or their life.
– The association class Union represents the husband–wife association.
- Describe how the following operations of class Person would be performed.
(You do not need to write code; simply describe how the available information would be used to compute the result.)
- Write OCL constraints expressing the following facts about the class diagram above.
B.1. You cannot die before you are born.
B.2. The date of a marriage always precedes the date of that marriage’s