[an error occurred while processing this directive]
Midterm Exam Review Questions
-
What is a design pattern?
-
How do design patterns benefit software developers?
-
Discuss the tradeoffs involved in the choice between inheritance and
composition.
-
In the Glyph class heirarchy (DP p. 38), why is it important to have a
common parent class?
What kind of pattern best describes this heirarchy?
-
Using an example, explain how the Strategy pattern can simplify code when
flexibility is an important consideration.
Can you give an example where this kind of flexibility is undesirable?
Then what pattern should be used?
-
Can a Strategy pattern be used as part of a Visitor pattern?
Describe how.
-
Give four examples of the Composite pattern.
For each one, indicate what plays the Leaf and Composite roles.
-
The Bridge pattern structure on page 153 of DP shows an aggregate
relationship between Abstraction and Implementor.
Do any of the Bridge examples in DP actually use an aggregate, as opposed
to a single reference?
Can you think of a reason for doing this?
- (6 points)
Draw a class diagram showing how an Abstract Factory is combined with a
Bridge. In the Bridge, the Abstraction classes are Component and its two
subclasses Button and Container (this is actually a Composite pattern).
There are two implementations of everything: Win95 and XWindows. Show all
classes involved and their inheritance and object reference relationships.
Also show with dotted lines which classes call constructors from other classes.
- (6 points)
In the file system example of the Pattern Hatching book, the author uses a
Template Method pattern to deal with destroying file system objects. Could
a Strategy pattern be used here instead? If yes, describe how. If no,
explain why not.
- (4 points)
In the file system example, could an Iterator be used instead of a Visitor
for dealing with added operations? Explain your answer.
-
FIXME.
[an error occurred while processing this directive]