Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Another singleton - should I use it?  RSS feed

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!