aspose file tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "singleton class " Watch "singleton class " New topic
Author

singleton class

Trader Joey
Ranch Hand

Joined: May 11, 2000
Posts: 33
Hi,
I was wondering how a singleton class differs from a class that has all static methods. Obviously, there is a single instance of the singleton class that is created before it can be used. But when would you use a singleton v/s a class that has all static methods ? pro and cons ?
Thanks
Nikhil
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Static methods cannot be ReMotedly Invoked.
It isn't possible to use polymorphism either.


SCJP2. Please Indent your code using UBB Code
Adrian Ferreira
Ranch Hand

Joined: May 29, 2000
Posts: 118
A singleton is an object like any other, first you design your class and after this you can transform it in a singleton. If you design your class using only static methods and statics attributes, you will be limmiting its usage.
For example, your singleton may also be modified to allow at most n instances. n = 1 is the most used.
Adrian
sonia jacob
Greenhorn

Joined: Aug 22, 2002
Posts: 5
I am new to design patterns.
Where can i find more information on singleton pattern and its examples
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by soniajacob:
I am new to design patterns.
Where can i find more information on singleton pattern and its examples

http://www.google.de/search?q=singleton+design+pattern
http://c2.com/cgi/wiki?search=singleton


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4118
    
    2

"soniajacob"
Please review the JavaRanch Naming Policy then
edit your profile to make your displayed name comply. (All you really need is a space between sonia and jacob)
Thanks for your cooperation


Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: singleton class
 
Similar Threads
NX: RandomAccessFile synchronization and record locking
Singleton Factory Object
Advantage of using Singleton over a class with static methods
Singletons
Singleton vs Class with singleton methods