Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

PART 3: Patterns > CHAPTER 9: Generating Objects

CHAPTER 9

Generating 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

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial