This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another singleton - should I use it?

 
Alana Sparx
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic