Chapter 22. Factory Pattern
The factory pattern consigns the task of creating objects to another class, called the factory. Factories take many forms. Factories can implement convenience constructors that simplify the construction of common objects by encapsulating repetitive or tedious preparations. They can be used to implement singletons and reusable pools of objects. But the most significant use is deciding the class of the new object on behalf of the client—the pattern we'll explore in this chapter. (A singleton factory pattern is described in Chapter 23).
The factory pattern is employed when the client—the code creating the object—cannot easily determine the class of the new object because it cannot know, or should not know, what class to ...
Get Learn Objective-C for Java Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.