UMBC  |  CSEE  |  Tarr  |  CS446

CMSC446 Introduction To Design Patterns

Spring 2005

Sample Test Questions For Test 2


1) What pattern allows you to use an existing class when its interface does not match the one you need?

2) Which design pattern is illustrated by the implementation of the Java I/O classes?

3) Both the Observer and the Chain of Responsibility patterns attempt to decouple sending and receiving objects. Compare these two patterns with regard to such decoupling.

4) To improve web page download times, a designer thinks it would be a good idea to have the browser pre-fetch all of the pages referenced from the page the user is currently viewing. But rather than have each individual client pre-fetch the pages from remote web servers, it would be even better if all the pre-fetched pages for a group of clients could be made available locally.

Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.

5) We are writing the software for a new electronic hand dryer. The dryer has a light sensor which can determine whenever someone's hands are placed under it. This triggers the dryer to start blowing hot air. The dryer can also be triggered via a push button on the unit. Once the unit starts blowing, we do not want additional pushes of the button or triggers of the light sensor to extend the air blowing cycle.

Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.

6) Company X has a large amount of applications software written using a particular class library. Company Y that wrote the class library has now gone out of business. Company X buys a new class library from Company Z that provides the same functionality as the previous library, but unfortunately many of the classes have different interfaces. Company X does not have access to the source code for the old or the new library. What should Company X do??

Select the most appropriate design pattern to use to address the problem and show how it is applied. In particular, show an appropriate class diagram(s) and enough code fragments to illustrate your use of the pattern to solve the problem.


Bob Tarr
University of Maryland, Baltimore County
tarr@umbc.edu
UMBC  |  CSEE  |  Tarr  |  CS446