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
posted
0
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
posted
0
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
posted
0
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
posted
0
Originally posted by soniajacob: I am new to design patterns. Where can i find more information on singleton pattern and its examples
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
"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