CHAPTER 9Generating Objects
Creating objects is a messy business. So many object-oriented designs deal with nice, clean abstract classes, taking advantage of the impressive flexibility afforded by polymorphism (the switching of concrete implementations at runtime). To achieve this flexibility though, we must devise strategies for object generation. This is the topic we will look at here.
This chapter will cover
- The Singleton pattern: A special class that generates one and only one object instance
- The Factory Method pattern: Building an inheritance hierarchy of creator classes
- The Abstract Factory pattern: Grouping the creation of functionally related products
- The Prototype pattern: Using
clone
to generate objects
Problems and Solutions in ...
Get PHP Objects, Patterns, and Practice, Second Edition 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.