• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add and delete methods on Data.java

 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though there does not need to be UI for adding/removing/updating the flights database, I've been implementing and unit testing these since we need to implement all of the public methods of data, and I realized that Data.getRecordCount() includes deleted records. I feel inclined to fix this, as my unit tests need to do things like add a new flight, search for it, and delete it, and after you delete a record, it's flight number is still searched as part of the uniqueness check, which complicates things. Anyone have thoughts on the strange requirement that we implement, but don't use this functionality? How did you deal with it? Right now, I'm leaning toward cleaning up Data.java a bit so it handles a mixture of live and dead records more smoothly, and that deleted records are ignored as much as possible.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add and Delete are in there because of a previous version of the SCJD where you had to write a conversion program.
You no longer have to do this, so just having it implementing is enough. You should not be adding or deleting records from your db.db file
Mark
 
Jim Bedenbaugh
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone have thoughts on the strange requirement that we implement, but don't use this functionality? How did you deal with it? Right now, I'm leaning toward cleaning up Data.java a bit so it handles a mixture of live and dead records more smoothly, and that deleted records are ignored as much as possible.

I echo Mark's thoughts. Further, it's possible that if you add functionality outside the requirements, you might not only not add to your score, but possibly hurt it.
I'd recommend you stick strictly to the requirements as defined. There's more than enough to worry about in those alone - at least there was for me!
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:
Add and Delete are in there because of a previous version of the SCJD where you had to write a conversion program.
You no longer have to do this, so just having it implementing is enough. You should not be adding or deleting records from your db.db file
Mark

Well by "it" I guess you would mean my "remote client code" that "must provide all the public methods of the suncertify.db class", but what do you mean by "implementing" if not "containing code that implements the functionality"? Do you mean I should have the methods with no-op implementations or something? Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ACtually all you need is
add(){
data.add();
}
So your DataAccessRemote class will just pass the call through. But no code in your controller or anywhere else will actually call the DataAccessRemote's add method.
Mark
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, my remote interface to Data is not an exact match, so I need more than just to pass the call on to Data.add() (just an extra line or two). My point is that if I write the code, I'm going to write unit tests that ensure that it works correctly (first), which I have done, but now my file has deleted records, which revealed that I had to change a bunch of other code to check for the null you get back when you call Data.readRecord() with a record number corresponding to a deleted record (like during a loop that gets all active records or a search), as well as a few other things that needed to be updated to be aware of the fact that Data.getRecordCount() includes deleted records. Anyway, my unit tests pass now and if Sun wants to take off points for me actually testing the code I submit, even though my app never calls it, it's their problem, not mine. Besides, with such excellent and intelligent posts from people like Mark, Michael, and Nate, I'm confident I'll have some points to spare.
And yes, I have the clean db.db file separately in CVS and will not use the modified one in my submission. Thanks for your comments!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds good Pete. Just remember to send the saved db.db in CVS to submit then they won't have deleted records.
But I also wanted to post my code for add in my DataAccessRemote, and tell me if yours is the same.


FBNDatabase is of course the instance of Data class

Mark
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, mine is similar, but I do not deal with DataInfo[] or String[] anywhere except in the .db package as I thought the most grievous shortcoming of the supplied code (and suggested design, which is awful) was the lack of business model objects, most notably Flight.java. So I have a a method FlightStore.addFlight(Flight newFlight), which does the conversion and eventually calls data.add(String[] newRecord). And even that is never called directly by the gui.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic