Re: Singleton vs. Static



Responding to Moop™...

Hi,
It is a long confused question to me, when to use singleton pattern but
not just using static declaration to class and fields, and when is vice
versa? Thank you!

You use the Singleton pattern when the problem space requires that only one object of a class can exist at a time AND

(1) there are multiple places in the application where the object could be created OR

(2) the object is created within some sort of iteration (i.e., the code of the create context is invoked multiple times).


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
"Model-Based Translation: The Next Step in Agile Development". Email
info@xxxxxxxxxxxxxxxxx for your copy.
Pathfinder is hiring: http://www.pathfindermda.com/about_us/careers_pos3.php.
(888)OOA-PATH



.



Relevant Pages

  • Singleton vs. Static
    ... It is a long confused question to me, when to use singleton pattern but ... not just using static declaration to class and fields, and when is vice ...
    (comp.object)
  • Re: Singleton vs. Static
    ... not just using static declaration to class and fields, ... You use the Singleton pattern when the problem space requires that only one object of a class can exist at a time AND ... the object is created within some sort of iteration (i.e., the code of the create context is invoked multiple times). ... I don't think the problem space doesn't have much to do with it. ...
    (comp.object)