The link you are reading, unfortunately, does not provide a realistic example of a template. In fact, according to the original GoF design patterns, this pattern is called the Factory Summary (the Factory method is another pattern).
The Factory abstract pattern is used when you have factories that can create a family of objects . for example, you can have AbstractGUIFactory , which can have the createButton(), createWindow(), createTitleBar , etc. And then you will have specific plants such as WindowsGUIFactory, MacGUIFactory, MotifGUIFactory , etc., Each of which will create Button, Window, TitleBar in its own way.
Factory will be installed on one implementation at some point in the application (possibly using the configuration), and then Factory will be used wherever objects need to be created.
If you study design patterns, it is best to start with the classic GoF book.
source share