Template Method

  1. Describe how Template Method pattern supports separation of an algorithm into an invariant core using varying behavior in subclasses.
  2. Describe how Template Method can be used to reduce code duplication by promoting commonality to upper classes in a class hierarchy.
  3. Explain the use of Template Method to support "hooks" that allow extended behavior at well defined places.
  4. Both Strategy and Template Method define algorithms. Contrast the differences between the two patterns.
  5. Explain how the Template Method pattern could use the Strategy pattern to define the algorithm's steps rather than inheritance.