There are 2 well-known factory templates:
- Factory Method Template.
- Abstract factory template.
The factory template method basically "addresses the problem of creating objects (products) without specifying the exact class of the object to be created." and the Abstract Factory template "provides the ability to encapsulate a group of individual factories with a common theme."
Method
Factory is used to create an Object, mainly by creating a factory interface of methods that subclasses can output and implement a method to create an object. This allows you to encapsulate without having to worry about who created the object, but you have an object made after the method was excluded.
The abstract factory template encapsulates collections together that have the same objective functions to complete the task. For instance. you can have a Button GUI and have a factory, such as WindowFactory , LinuxFactory , AppleFactory , which can create these buttons. Wrap these factories in an abstract factory in such a way that, by providing the OS, it will return the specific OS factory to create the Button .
I hope this is clear. Sorry for not using the correct English constructive sentences.
source share