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

Carleton University

Department of Systems and Computer Engineering


SYSC-3020 Introduction to Software Engineering Fall 2021

Assignment 3
Submit one document with your answers on Brightspace. After submitting, make sure your material has
indeed been received by Brightspace without any problem.
[TOTAL: 30 marks]

Question 1. [5 marks]
Using the example of the Trip Planning Software discussed in class (see the class diagram on
systemdesign_part2 slide 20), 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. You are also asked to 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?
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. You are also asked to illustrate in a class diagram what
the use of the pattern would look like.

Question 3. [5 marks]
Suppose that you are asked to provide a design solution for pluggable software components, i.e., a design
where components are viewed as clients and servers, where a server can be replaced with another one
without affecting the client.
Specifically, suppose that your software is to support sales and needs to compute taxes on sales. Analysis
has produced a class Sale that can specify several items being sold, a control class to compute taxes on
such sales, and a class TaxCalculator that provides an operation getTaxes(Sale) and returns a list of tax
values, one tax value for each item being sold as part of the Sale instance: indeed, different items may be
subject to different taxes.
Suppose that different customers (of the software you are building) are requesting that the software
support pluggable components for tax calculation: specifically, calculating taxes could be provided by
TaxMaster (a third party software), TaxWeb (a web service). The interface of the services these third
party components provide cannot be changed. Additionally, you do not want to change the control class
mentioned above since you would have to change it for every new third party service customers would
like your software to use (not practical).
What design pattern would you use? Justify your answer. Describe the solution and corresponding class
diagram, using the design pattern you selected. Use code excerpts where necessary.

Question 4. [5 marks]
Carleton University
Department of Systems and Computer Engineering
SYSC-3020 Introduction to Software Engineering Fall 2021
The class diagram below illustrates a problematic situation where client classes have too many
relationships with subsystem’s classes.
What design pattern would you use to solve this problem? Justify your answer. Describe the solution and
corresponding class diagram, using the design pattern you selected. Use code excerpts where necessary.

Question 5. [10 marks]


Suppose the behavior of class M is specified with the following state machine.
evt3 / a2

state1 evt1 / a2 state2


exit a1 entry a3
exit a4

state3
entry a4 evt4 / a6
evt2

state5 state4
entry a5 evt3 / a6 exit a5
evt2

a. [10 marks] Using the (extended) state design pattern, what will be the structure of the class
diagram and what would be the responsibilities of the different operations (shown in pseudo code)
for realizing the desired behaviour? (Hint: see slide 21 from sysc3020_4_systemdesign_part4)

You might also like