• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing database/data layer without using Singleton method

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Just wondering if I don't use the Singleton pattern for the Data layer of my project, for testing purposes, would I have to use multiple instances of my Data class in testing? For example, say I was testing multiple-threading of 50 reads. Would I need to say, test 25 of these using 1 instance of my Data class and another 25 say using another instance? Basically what I am asking is if one does not use the Singleton pattern for the Data layer when accessing the database functionality, do they have to test application across multiple instances of the data class?
Thanks.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

That all depends on how you implemented concurrency and making the data class thread-safe. Many possible alternatives to ensure thread-safety, so it has little added value to elaborate on it.

And if you implemented your singleton pattern correctly, you should not be able to create multiple instances of your Data class. Because if you can do it for testing purposes, you also can do it for developing (production) purposes and the singleton pattern is not applied correctly.

Kind regards,
Roel

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic