Orphans adoption and surrogates singletons
Download
1 / 7

Orphans, Adoption, and Surrogates Singletons - PowerPoint PPT Presentation


  • 129 Views
  • Uploaded on

Orphans, Adoption, and Surrogates Singletons. Josh Mason June 1, 2009. Adoption and Orphan. Adoption 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. Singleton.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Orphans, Adoption, and Surrogates Singletons' - scout


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Orphans adoption and surrogates singletons

Orphans, Adoption, and SurrogatesSingletons

Josh Mason

June 1, 2009


Adoption and orphan
Adoption and Orphan

  • Adoption

    • 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.


Singleton
Singleton

  • Creational Pattern

  • Restricts instantiation of a class to a single instance


Uses

  • To implement other patterns

    • Abstract Factory

    • Builder

    • Prototype

    • Façade

  • State Objects


Singleton benefits
Singleton - Benefits

  • Single Instance

  • Controlled Access

  • Reduced Namespace

  • Lazy Initialization

  • Easily extends to allow for a variable number of instances.

  • Can assist in making thread safety simpler.


Singleton examples
Singleton - Examples

  • Traditional

    • staticMyClass* Instance();

  • Alternative 1

    • staticMyClass* Instance(inti_id);

    • static MyClass* Cleanup(inti_id);

  • Alternative 2

    • staticCreate(inti_val, float i_val2);

    • staticMyClass* Instance();

    • staticCleanup();


Stinkleton issues
Stinkleton* - Issues

  • Why not just use global variable?

  • An anti-pattern?

  • Creation

  • Cleanup

  • Tight coupling

    * Robert Penner


ad