Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Speaking strictly from a language standpoint, by default, the Singleton instance is unique to each application process if you are using it within a typical desktop or console application. This is because the instance that is created is marked with as "static". There are threading techniques that can be used to make multiple instances that are unique to their originating thread (as may be done in a web server context), but typically Singleton is used to ensure that all callers get the same instance.
Greg Lusk, May 31, 2011
Reply 2
To add to this, by nature Singleton returns single instance and is meant to provide a global point of access to resources.  This being its main intent there may be variations of this wherein you can have single instance per application, per user, per role or other criteria.  But I am not sure whether that will be called Singleton or any other pattern already exists which solves this problem.

But yeah any pattern can be adopted to the applications need, as long as the core intent remains the same otherwise you create a new pattern and if enough support exists, may be, that can form part of the design patterns catalog :)



Rajesh Pillai, Sep 28, 2010
Reply 3
Hi,

It depends on the situation and environment. For eg. MS Word which is a desktop application, creates a singleton object per user ie each user logged on to windows user account can open one instance of MS Word.

While in a web application, if an object is implemented as an Application Level object and singleton, then only one instance of that object will be created until the application lives.

While, if your application is an online store and allows each seller to have a customized store, and the implementation of the store is a singleton object, to avoid a seller creating multiple stores, then the singleton instance will be created for each user.

I hope it helps.
Sameer Goyal, Sep 28, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas