1 / 7

PH page 18-24 GoF Singleton p. 127-134

PH page 18-24 GoF Singleton p. 127-134. Emanuel Ekstrom. Orphans & Adoption. Context: Making a file system. Three objects: Node, File, Directory. Why do we need to adopt? Why do we need to orphan? Who gets an adopt/orphan interface? So are they all the same?. Singleton. Intent:

laith-lopez
Download Presentation

PH page 18-24 GoF Singleton p. 127-134

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PH page 18-24GoF Singleton p. 127-134 Emanuel Ekstrom

  2. Orphans & Adoption • Context: Making a file system. Three objects: Node, File, Directory. • Why do we need to adopt? • Why do we need to orphan? • Who gets an adopt/orphan interface? • So are they all the same?

  3. Singleton • Intent: ”Ensure a class only has one instance, and provide a global point of access to it.”

  4. Discussion • Who needs only one instance? • What is good about a global access point? • Why not global variables instead?

  5. How do we make a Singleton? (GoF p. 131) • Constructor protected • Public static Instance() function. • Is this enough?

  6. Discussion • What if we want to delete a Singleton? • What if a deleted Singleton is called? • Is there a solution to the problem?

  7. Subclassing • Problem: Making sure the subclasses are unique and that the clients can access it. • How is this solved? • Drawbacks?

More Related