Instantiating – NEW’ing – objects can be tricky: especially if the developer wants to be 100% sure that they have a valid object. “Valid” being an object with correct default values, with all required dependencies satisfied, being fully initialized and ready to be worked on. Add in the fact that requirements and classes change – usually becoming more complex – over time, and knowing how to get a valid object becomes harder.
The Factory pattern and its relatives provide a way in which application infrastructure or frameworks can guarantee that a developer gets what they are asking for. This session will cover the patterns themselves, how to implement them, and why you would want to (and not).