
Software Patterns – Factory Method
We continue our exploration of the creation patterns with a look at the Factory Method. This is a pattern where we see that instantiation is sometimes better when deferred. We do not always know all we need to at instantiation time. Thus, we need a pattern to address holding off on that step until we have the required information. The Factory Method Defined It helps to start with the “Gang of Four” definition and then we will dig into that. Define an interface for creating an object, but let subclasses decide which class to instantiate. The Factory method lets a class defer instantiation it uses to subclasses. This pattern allows us to roughly replace the constructor for a class with retrieving an instance... Read more