File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what are the conditions to be followed in creating a singleton class or design?

 
senthil sen
Ranch Hand
Posts: 184
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are the conditions to be followed in creating a singleton class or design?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Singleton is merely a Design Pattern. Implementations can vary greatly, especially among languages.
In Java, a Singleton is typically implemented with a public static method that maintains and returns a single instance of the class. The construction of the class outside this static method is forbidden by setting the acessibility level of the Constructor to private.
Example:

For further information on Singletons, swing by the OO, Patterns, UML and Refactoring Forum where this topic is of frequent discussion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic