CS 150 Lecture 7, 9/20/00: Strategy Pattern continued

Home Java Resources Discussion Dropoff
  1. Coin Counter Example continued.
  2. Strategy Design Pattern

    1. Behavior as an object -- execution of a strategy.
    2. The abstraction of a strategy.   Does the context care about what really happens?
    3. The abstract strategy hierarchy.   Abstract vs. concrete strategies.
    4. The separation of the variant and invariant behaviors of a system:   Encapsulate the invariant into an object and abstract the variant into an abstract hierarchy tree.    The invariant deals with the variant only at the abstract level.
    5. Strategies give us the ability to modify the behavior dynamically, that is, during the execution of the program. 
    6. The strategy pattern eliminated the subclasses of Ball and replaced it with smaller, simpler subclasses of AStrategy that encapsulate only the differences between the behaviors of different types of Balls.
    7. The use of "indirection" allows us to change what's going on "behind the scenes".   For instance, all the behaviors of all the Balls can be changed at once.
    8. Display strategies example