Understanding the Factory pattern
The Factory pattern is a creational design pattern. This means that it solves a particular problem related to how we will create objects in our application, or in our case, in our games. The singleton pattern is another creational design pattern, for reference, as it addresses how to create a given object. In the Singleton pattern’s case, it ensures that a given variable always points to only one instance of the same object. This variable is made static, allowing any object to access it. In the case of the Factory pattern, it allows us to instance a family of objects without specifying their types, and these objects are known as products. It does it so that we can centralize common procedures and prevent duplication of these procedures in multiple classes; instead, these classes become user classes of the Factory classes.
One of the most fundamental aspects of the Factory pattern is that it is not supposed to be a single class that handles...