|
In this session we will cover the following design patterns:
- the visitor pattern: we use it to decouple the extrinsic algorithms on
AList from the intrinsic structural behavior of AList, and transform the scheme-like list
structure AList designed in session 2 into an flexible and extensible framework .
- the state pattern: for a list to be mutable, it must be able to change
its state dynamically from empty to non-empty and in the process change its behavior at
run time. This problem of "dynamic reclassification" can be solved by
applying the state design pattern.
- the template method pattern: we formulate sorting as the template
method of an abstract class that carries out sorting as a divide-and-conquer
algorithm; the tasks of "dividing" and "conquering" are relegated to
concrete subclasses.
|