CS4015 Review Guide
A. Concepts
1.
The purposes
and differences of creational, structural, and behavioral patterns.
2.
The differences
of class scope and object scope patterns.
B. General for each pattern
1.
Motivation
l
Understand
the motivation example problem and how the pattern help solves the problem.
2.
Applicability
l
Understand in
what cases the pattern can be applied.
l
Given an application
problem, identify if the pattern can be applied to help solve the problem.
3.
Structure,
Participants, and Collaboration
l
Memorize the
structure diagram and all its participants.
l
Given an
application problem to be solved by the pattern, mapping the corresponding
entities to the participants of the pattern.
l
Given a
structure diagram of a pattern, identify the pattern.
l
Identify two or
more patterns have same or similar structures.
l
Write an implementation
of the pattern exactly according to the pattern structure.
4.
Consequences
l
Understand
each benefit and liability of the pattern.
l
Given an
application problem that is intended to be solved by the pattern, decide if the
pattern can be applied for benefit.
5.
Implementation
l
Make sure to
understand each special implementation issue for the pattern clearly.
l
Given an
application problem, a pattern to solve the problem, and an implementation
issue, try to write the implementation based on the solution to the issue.
6.
Related
Patterns
l
Make sure to
understand the relationship of each pair of related patterns the relationship
diagram of all the patterns given in the textbook.
l
Make sure to
understand that there two types of relationships between this pattern and other
patterns:
a) This pattern is usually used together with other patterns. How to implement these patterns together in a program.
b)
Thus pattern
is in some way similar to another pattern. What are differences of the two
patterns in terms of their structures and/or their applications?
C. Patten Specific
1.
Adapter
l
Given two classes,
write an object and/or a class adapter to adapt one class’s interface to the
other class.
l
Given a
program using a class adapter, rewrite it using an object adapter, or vise
versa.
l
Understand in
what case class adapter should be used and in what case object adapter should be
used.
l
Understand
what is pluggable adapter, what is the purpose of pluggable adapter, how to
implement it.
2.
Bridge
l
Given a
program with mixed logical and implementation inheritance hierarchy, rewrite
the program using the bridge pattern to separate the logical and implementation
hierarchy.
3.
Composite
l
Given the
description of a recursively defined nested structure, using the composite
pattern to implement the structure.
4.
Decorator
l
Given an
application problem, identify if the problem can be solved using the decorator
pattern or other patterns such as strategy or proxy.
l
Implement the
decorator pattern for a particular application problem.
5.
Flyweight
l
Given an
application problem, identify if the problem can be solved using the flyweight
pattern.
l
Given an
application problem to be solved using the flyweight pattern, identify what is
extrinsic and intrinsic states of flyweights.
l
Implement the
flyweight pattern for a particular application problem, which may be combined
with other patterns.
6.
Proxy
l
Understand
what are remote proxy, virtual proxy, protection proxy, and smart reference,
their purposes, and their distinct behaviors.
l
Given an
application problem, identify using what kind of proxy can help solve the
problem.
l
Implement each
kind of proxies for particular application problems.
7.
Chain of
Responsibility
l
Given an
application problem, identify if the chain of responsibility pattern is a better
choice to help solve the problem compared with other patterns. If yes, how to
do it.
l
Given a
program that partially solves an application problem, to add a chain of
responsibility into the program to complete the solution, how to build the
chain with an existing chain in the program or creating new a chain.
l
Implement the
chain of responsibility pattern for a particular application program.
8.
Command
l
Given an
application problem, identify if the command pattern can help solve the
problem. If yes, how?
l
Implement the
command pattern for a particular application problem with or with support for
undo/redo?
l
Implement
execute and un-execute operation for a command object combined with using
memento objects.
9.
Memento
l
Given an
application program that needs to preserve object states, how to use memento pattern
to solve the problem?
l
Determine
narrow and wide interface for a memento object in a particular application.
l
How to
support incremental state change in implementation of the memento pattern.
l
Implement memento
pattern for a particular application program.
10. Iterator
l
Given a
container or aggregate class, write an external iterator for the class, with
standard primitive operations. Also write an application of the iterator.
l
Given a
container or aggregate class and an application on the class, write an internal
iterator for the class based on the application.
11. Visitor
l
Given a
object structure where objects in the structure are instances of several
classes, iterators for the aggregate objects in the structure, and applications
on the structure, using the visitor pattern to implement the applications.
12. Observer and Mediator
l
Given an
application problem that need object collaboration, determine if the observer
pattern or mediator pattern should be used to help solve the problem. How to
implement the selected pattern for the problem.
l
Implement the
observer pattern with change manager that can be implemented using the mediator
pattern.
l
Implement mediator
pattern using the observer pattern.
13. Strategy
l
Given an
application problem, identify if the strategy pattern can be applied to help
solve the problem.
l
Given a set
of alternative algorithms, and a dynamic algorithm selection policy for an
application program, implement the program using the strategy pattern with
proper context and strategy interfaces.
14. State
l
Given a state
diagram of a class, implement the class using the state pattern based on the
state diagram.
l
Given a class
implementation, rewrite the class implementation using the state pattern.
15. Template Method
l
Given an
implementation of the template method pattern, identify concrete operations,
concrete AbstractClass operations, primitive operations, factory methods, and
hook operations.
l
Given an
application problem, identify if the template method pattern can help solve the
problem, and how.