Objects can instantiate other objects directly by calling the new
keyword, but this approach is often not the best choice.
Instantiating the object is a separate responsibility that should be carried over from the client code to separate classes/methods called factories.
Using a Factory design pattern has the following benefits:
There are many variations of a Factory pattern, each of which solves a different problem.
#design-patterns #software-development #software-engineering #web-development #programming #cplusplus