Orphans, Adoption, and Surrogates

Orphans, Adoption, and Surrogates Orphans, Adoption, and Surrogates - Start

Added : 2018-11-08 Views :5K

Download Presentation

Orphans, Adoption, and Surrogates




Download Presentation - The PPT/PDF document "Orphans, Adoption, and Surrogates" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.



Presentations text content in Orphans, Adoption, and Surrogates

Slide1

Orphans, Adoption, and SurrogatesSingletons

Josh Mason

June 1, 2009

Slide2

Adoption and OrphanAdoption

Taken ownership of object

Orphan

Relinquish

object

What’s the purpose?

Deciding where to put adoption/orphan functions

Component? Leaf? Composite?

Case by case basis.

Slide3

SingletonCreational Pattern

Restricts instantiation of a class to a single instance

Slide4

UsesTo implement other patterns

Abstract Factory

Builder

Prototype

Façade

State Objects

Slide5

Singleton - BenefitsSingle Instance

Controlled Access

Reduced Namespace

Lazy Initialization

Easily extends to allow for a variable number of instances.

Can assist in making thread safety simpler.

Slide6

Singleton - Examples

Traditional

s

tatic

MyClass

* Instance();

Alternative 1

static

MyClass

* Instance(

int

i_id

);

static

MyClass

* Cleanup(

int

i_id

);

Alternative 2

static

Create(

int

i_val

,

float

i_val2);

static

MyClass

* Instance();

static

Cleanup();

Slide7

Stinkleton* - Issues

Why not just use global variable?

An anti-pattern?

Creation

Cleanup

Tight coupling

* Robert

Penner


About DocSlides
DocSlides allows users to easily upload and share presentations, PDF documents, and images.Share your documents with the world , watch,share and upload any time you want. How can you benefit from using DocSlides? DocSlides consists documents from individuals and organizations on topics ranging from technology and business to travel, health, and education. Find and search for what interests you, and learn from people and more. You can also download DocSlides to read or reference later.
Youtube