Chapter 16
- The factory pattern makes it easy to keep track of the objects that are created within a program. Another benefit lies in the separation of code, which creates an object and the code that the object uses.
- There are two forms of the factory pattern: the factory method and the abstract method. The former is used to handle the creation of a single object, while the latter is a group of factory methods.
- You should start with the factory method first since it is the simpler of the two. If you find yourself needing many factory methods, then you should start thinking about grouping them into different abstract methods.