aspose file tools*
The moose likes Beginning Java and the fly likes Need Realtime exa. of Singleton class??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need Realtime exa. of Singleton class???" Watch "Need Realtime exa. of Singleton class???" New topic
Author

Need Realtime exa. of Singleton class???

jone wars
Greenhorn

Joined: Jan 22, 2013
Posts: 3
i need realtime example of singleton class.
when should we go for singleton class???
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

Almost never. You could say enums are singletons so that might be the only good example of use. Singletons are difficult to test, easy to missuse and tent to end up in a "Oh actually i need more than one" situation.


Please correct my English.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7823
    
  21

jone wars wrote:i need realtime example of singleton class.
when should we go for singleton class???

I agree with everything Manuel said - almost never - however, one well-known use of singletons is for a logger (ie, the encapsulation of a logging service).

For more information, I suggest you read this.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Realtime exa. of Singleton class???