Yes. This sounds correct. Both in factory as well as template method:
- base class is abstract. In factory, you intend your child classes to come up with your own implementations, whereas in Template you want child classes to implement some extra functionality(other than what is done in base class)
Only difference is that in Factory you return diff object of child class depending on run time behaviour.
In template method pattern, the skeleton of an algorithm is defined in the superclass. The implementation of some steps are deferred to the subclasses. In other words, it provides a framework where a subclass can redefine an algorithm encapsulated in the superclass without changing the algorithm's structure. The methods which are left abstract in the superclass and implemented in the subclass are called primitive operations. The method that defines the algorithm using the primitive operations is called the template method. A template method / primitive operation can do anything and there are no restrictions on what you can do in them
In the factory method pattern, you define an abstract factory method in the superclass and implement it in the subclass. But when you implement it, you can only create an object in the factory method and return it to the caller and the caller uses the created object in some way . Hence there is a restriction on what you can do in a factory method. Hence factory method pattern is a more specialized form of the template method pattern. Both of them use inheritance to defer implementation to subclasses.