design-patternsstrategy-patterntemplate-method-pattern

Difference between Template Method (separation) and Strategy pattern?


My teacher is a really good one and I tend to understand his points, but this one just goes over my head. He explains Template Method in two variants;
- Unification: the standard variant, that is composed of an abstract class with some abstract methods defining the variant parts of the otherwise fixed algorithm.
- Separation: his own variant (I think?) where a class contains the templateMethod() and uses delegation to an interface to vary the parts of the algorithm, which looks to me exactly like the Strategy pattern.

Can anyone see what his point is, and how the 'separation' variant is different from the Strategy pattern?
I have attached an image containing the two patterns from his book (which isn't published yet).

http://img64.imageshack.us/img64/3620/strategytemplate.jpg


Solution

  • I have never heard of a "Separation variant" of the Template method pattern, and I agree that it looks extremely similar to the Strategy. Even if there is some reasoning about interface ownership or how you invoke them from a client perspective I hardly find there's any benefit to consider them different patterns.