• 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

NX: Data constructor dependency - KEN???

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the Data singleton approach. I have a no-argument constructor that depends on the database file location from my properties file. Also, I plan to submit with no properties file and let the system build one after the user enters the values.
I could add a constructor that accepts the file name, but I recall reading out here somewhere that a singleton constructor typically should not accept arguments.
Will this get me in trouble for the automated testing? Say, for instance, if their automated test runs before they even use the GUI to choose the database location. I plan to document this, but could I fail the automated testing before they even look at my documentation?
Thoughts?
Ken - I would also be interested in your opinion since I know you were the singleton approach and passed with flying colors.
TJ
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Terry,
I'm not familiar with the restriction that a class implementing the singleton design pattern shouldn't take parameters. Of course, the classic singleton design pattern implementation:

needs to be altered slightly if the constructor takes parameters as follows:

Hope this helps,
George
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TJ,


I use the Data singleton approach. I have a no-argument constructor that depends on the database file location from my properties file. Also, I plan to submit with no properties file and let the system build one after the user enters the values.


My approach was exactly the same as this.


I could add a constructor that accepts the file name, but I recall reading out here somewhere that a singleton constructor typically should not accept arguments.


I don't know about why this recommendation was made.


Will this get me in trouble for the automated testing? Say, for instance, if their automated test runs before they even use the GUI to choose the database location. I plan to document this, but could I fail the automated testing before they even look at my documentation?


I doubt that the test program is that automated. The examiner more than likely has to manually tell the testing program how to acquire an instance that implements the database interface as everybody may use a different approach.
 
Let nothing stop you! Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic