Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Another singleton - should I use it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Another singleton - should I use it?" Watch "Another singleton - should I use it?" New topic
Author

Another singleton - should I use it?

Alana Sparx
Ranch Hand

Joined: Feb 14, 2006
Posts: 121
I have an abstract parent class that contains a static initialiser block, which in turn calls a number of protected methods that load a number of Maps with data from a data source.

I have two sub-classes, one of which will provide the opportunity to update the data source, reload the appropriate Map and return the reloaded Map. I think this class should conform to the singleton design pattern.

Another class however will only ever allow you to read data from another two Maps (there will never be a case to update these maps from the application code). I'm of the opinion that the singleton here is not appropriate as there is no chance of a database update whilst someone reads 'dirty' data from the Maps. Should I just provide static accessor methods on the sub-class to retrieve data from these maps? The traffic into these maps could get quite heavy.

Mant Thanx
As
 
wood burning stoves
 
subject: Another singleton - should I use it?
 
Similar Threads
hashCode/equals stratgy for mutable object
Passed SCJD - 366 /400
Locking
Question regarding the singleton data and synchronized method approach
Some details about my solution