• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Data constructor dependency - KEN???

 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • 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
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • 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
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic