Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird] Data class default constructor

 
Barend Garvelink
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,


A bit of advice. The instructions document mentions automatic grading and specifies an interface for the Data access class. This makes for a credible assumption that they'll run a bunch of JUnit tests on the data class.

However, the instructions document does not restrict the Data class in any way, specifically, it does not mention any requirements to the constructor signature.

My preferred constructor takes a java.io.File as its single argument. I have included a no-arg constructor that uses the default database file on the default location, but this is bad design and its presence in my application annoys me.

I found a previous discussion about this on this forum:
http://www.coderanch.com/t/183606/java-developer-SCJD/certification/NX-contractor-Stand-alone-Data
but it's from over a year ago and doesn't mention how things turned out in grading.


I think it's reasonable to have the Data class take a File parameter in its constructor, and that removing the no-arg constructor should not be grounds for automatic failure. I would like to be sure though, so my question is: has anyone submitted a Data class without no-arg constructor? How did it turn out?

Thanks,
Barend
 
Omar Kalaldeh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In the instructions there no resections on the Data class constructor, so I think you can put any constructor you need.

In my data class I have one constructor witch takes a String parameter (fileName). Hopefully tonight I will submit my assignment, and maybe in week or more we will know if it acceptable or not.


 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barend,

There have been many different implementations of the Data class that have passed, and they have had different requirements for their constructors. For example: some of them have been Singletons, some of them have relied on only one instance ever being instantiated, and some of them have relied on multiple instances being instantiated.

Perhaps Sun have a suite of test suites so that they can handle the more obvious choices?

Regardless, they haven't specified anything about the constructor, so you are free to have your constructor take a File as an argument.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic