PH page 18-24 GoF Singleton p. 127-134 - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

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

Description:

PH page 18-24. GoF Singleton p. 127-134. Emanuel Ekstrom. Orphans & Adoption ... Why do we need to adopt? Why do we need to orphan? Who gets an adopt/orphan ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 8
Provided by: Man144
Category:
Tags: gof | ekstrom | page | singleton

less

Transcript and Presenter's Notes

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


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?
Write a Comment
User Comments (0)
About PowerShow.com