Yes - choosing a design template sometimes moves logic rather than replacing it.
I really do not understand your objection. Some logic of the solution is already in the client, and the strategy consolidates the solution.
In your code example
void Composition::Repair () { switch (_breakingStrategy) { case SimpleStrategy: ComposeWithSimpleCompositor(); break; case TeXStrategy: ComposeWithTeXCompositor(); break;
the _breakingStrategy field should be provided somewhere, presumably, by client code that determines which layout method to use and pass the result of this decision as the value of _breakingStrategy .
The only thing that the Strategy applies is that this solution provides a subclass of the Strategy instead of the "type code", as it is now, of consolidating the solution.
The decision, of course, must be made somewhere. If you think that the Composition::Repair method is suitable for it, you, of course, may not use the strategy template at all.
If you want to use the Strategy, but do not want the logic in the client (no more than it is), the Factory method containing a similar switch could provide it.
source share