Module 12.F Pre-Class Worksheet
Module 12.F Pre-Class Worksheet
The following worksheet is based on Module 12.F Pre-Class (Design Patterns II). As
usual, you should create a personal copy of this worksheet, fill it out, and submit it to
Canvas prior to the deadline.
1. Fill in the following chart for the three design patterns discussed in the Design
Patterns II video.
3. What is double dispatch, and why is it necessary in the visitor pattern? You
should address the need for the accept() method as well as the need to
re-define the accept() method within each concrete subclass of IVisitable.
[Your answer]
4. The strategy and visitor patterns are similar in that they both decouple an
algorithm from the class on which it operates. What is the key difference between
them? (Hint: it has to do with the nature of the object that the algorithm operates
on, and how the nature of that object influences the algorithm itself!)
[Your answer]
The left column of the following table describes several tasks that you’re trying to
accomplish. Fill in each cell in the right column with a number between 1–8
corresponding to the design pattern from the list above that is the best fit for the
task described in that row. Determine the best fit based on the goal of the task,
the existing infrastructure, and the principles taught in COMP 215.
You want to help the client find the optimal mode of transportation for [Your
a single leg of their journey. You have a database that rates each answer]
possible combination of (mode of transportation, source, destination)
according to a variety of different metrics such as speed and
comfort. You want the client to be able to choose a single metric to
maximize, and you will then search your database for the optimal
mode of transportation based on that metric.
You want to design a user interface for browsing available tickets for [Your
a given leg of the client’s journey. You want this user interface to answer]
always stay up-to-date with the latest information about available
tickets. Information about ticket availability can also be found in the
database. Each time the information in the database changes, you
want the user interface to automatically refresh in order to reflect the
most up-to-date ticket availability.
6. Which of the above questions are you unsure about the answers to? List the
question numbers here so that you remember to discuss them with your group
during class. If you don’t have any questions, you can answer this question with
“N/A” (not applicable).
[Your answer]
7. What other questions do you have related to today’s material that you want to
discuss with your group / the staff during class? If you don’t have any questions,
you can answer this question with “N/A” (not applicable).
[Your answer]