• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Singletons
 

Singletons

on

  • 645 views

 

Statistics

Views

Total Views
645
Views on SlideShare
643
Embed Views
2

Actions

Likes
0
Downloads
27
Comments
0

2 Embeds 2

http://www.linkedin.com 1
https://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Singletons Singletons Presentation Transcript

    • Iwan de Beer
      • Ensure that a Class has only one Instance
      • Provide a Global Reference to the Instance
      • Where can you use it?
      • Attributes
      • Requirements
      • Advantages and Disadvantages
      • Singleton versus Static Class
      • Multi-Threading
        • State Objects
          • ie. Global Application Settings
        • Data Access Objects
          • ie. Sharing DataContexts
        • Utility Classes
          • ie. Global Utility Classes
      • Single Instance at Runtime
      • Responsible for own Creation
      • Lazy Instantiation
      • Private, Parameterless Constructor
      • Public Static Read-Only Instance Property
      • Sealed
      • Simpler Consumer Code
      • Less Overhead
      • Cleaner than a Collection of Global Variables
      • Global State
      • Over Use Anti-Pattern
      • Compiler responsible for Instantiation of Static Class
        • Developer cannot control when the Static Class is Instantiated
      • Singleton Class responsible for Instantiation
        • Some degree of control over when the Singleton Class is Instantiated
      • Instance Property
        • Static Class is accessed by the Class Name – No access to the Instance
        • Singleton is accessed by Instance Property
      • Thread-Safety
        • Creation
        • Methods
      • [ThreadStatic] Attribute
        • Single Instance per Thread
        • Workaround when Methods aren’t Thread-safe
      • http://en.wikipedia.org/wiki/Singleton_pattern
      • http://www.yoda.arachsys.com/csharp/singleton.html
      • http://msdn.microsoft.com/en-us/library/ms954629.aspx
      • http://msdn.microsoft.com/en-us/library/ms998558.aspx
      • http://msdn.microsoft.com/en-us/library/ms998558.aspx
      • http://aspalliance.com/827_Gang_of_Four_GOF_Design_Patterns.all