The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Static Members



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Not really..

Posted by ashutosh on July 07, 1999 at 9:56 AM

Singleton pattern results in ONE "instance". Not just a class. As far as I know. And I haven't read the relevant article.
Now, just calling Class methods doesn't mean you have a singleton.
And your comment about "it's a matter of style and not procedural programming practise" is not correct. People do tend to use just the class methods becuase that's what they did in proc. langs.
A true singleton should produce one and only one instance and messages should be sent to that instance and not the class.

That's just my opinion, I could be wrong.

> In an application I'm developing I have a singleton class
> which provides basic services used throughout the application.
> The singleton is implemented using statics. I do not believe
> the question of object-oriented versus procedural programming
> applies here. It is one of style.

> For a singleton accessed in many places, ClassName.method()
> seems to me to be more readable than
> ClassName.getInstance().method. Since the concensus
> is not to use statics for singletons I will probably change
> it, but I am not completely convinced.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us