Paranoidal Singleton (codingroute.blogspot.com)

submitted by ksh2dotnetkicksksh2dotnetkicks(135) 2 years, 3 months ago

1 - If one object must have at most one instance in an application, then no one must be able to capture a pointer to it in any other scope. In other word's it should have at most one pointer to it in whole application, too. Otherwise it's lifetime and service access can not be controlled. So there must be a proxy to that object and at any time, just one of these proxies has access to the actual instance. 2 - In Singleton pattern, if the single instance object have any kind of changing states then it will become a source of disaster (as any other global state in the application). So it is not just enough to provide a thread-safe pointer access. Instead we need a working scope for our singleton object. Using proxy pattern we can achieve this goal: at anytime there is just one pointer to singleton and there is just one user for it.

add a comment |category: |Views: 2

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story