Assignment #6 -- Design Pattern exercises
Due: Fri, April 20
Task
Complete a set of exercises from the textbook on design patterns. The
exercises are: 8-5, 8-7, and 8-8 (on pages 342-343).
Exercise 8-5
Consider a system that includes a database client and two redundant
database servers. Both database servers are identical: the first acts as a
main server, the second acts as a hot back-up in case the main server
fails. The database client accesses the servers through a single component
called a "gateway", hence hiding from the client which server is currently
being used. A separate policy object called a "watchdog" monitors the
requests and responses of the main server and, depending on the responses,
tells the gateway whether to switch over to the back-up server.
What do you call this design pattern? Draw a UML diagram to justify
your choice. (Also, explain your choice briefly).
Exercise 8-7
Consider the following design goals. For each of them, indicate the
candidate pattern(s) you would consider to satisfy each goal.
- Given a legacy banking application, encapsulate the existing business
logic component.
- Given a chess program, enable future developers to substitute the
planning algorithm that decides on the next move with a better one.
- Given a chess program, enable a monitoring component to switch
planning algorithms at runtime, based on the opposing player's style and
response time.
- Given a simulation of a mouse solving a maze, enable the path
evaluation component to evaluate different paths independently of the
types of moves considered by the mouse.
Additional: For each of these, give a short explanation for why the
pattern you chose fits the situation. (i.e. don't just list the pattern
name -- explain your choice).
Exercise 8-8
Consider an application that must select dynamically an encryption
algorithm based on security requirements and computing time constraints.
Which design pattern would you select? Draw a UML diagram depicting the
classes in the pattern and justify your choice.
Submitting
You will submit this one electronically, since the due date is not on a
class day. Put your work into a document of one of the following formats:
- Rich Text File
- MS Word Document
- PDF
Your file should be set up so that it will print onto standard
size paper (8 1/2 x 11). It can print on multiple pages, but it
should print as-is, without having to reformat the file in any way.
Your document should include a header with your name and section number.
Document contents: Written answers for each exercise, as well
as any diagrams required, pasted in so that they fit within printable
boundaries.
Filename should be one of the following (depending on document type):
E-mail this file to me (myers@cs.fsu.edu) by the due
date. Your e-mail subject should be HW6-SUBMIT. Include your name
and section in the e-mail body. Please only submit ONCE, unless you make
a mistake and need to correct it (before the due date) -- and minimize
this. Only the last submission will be graded.
Your submission e-mail needs to come either from your CS account
(preferred) or your garnet/mailer account.