• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Deleting Records

 
Matthew Melvin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've read a couple of threads on this and not come up with an answer. My interface contains the following....



Firstly, there is no must here so I'm not considering this mandatory.
Additionally, since the description is not in javadoc format I don't consider it to constitute a contract for all implementations. (If I was implementing without the benefit of the source file I wouldn't be able to see this information and so it would have no bearing on my design).

For simplicity, my intention was simply to use a logical delete by marking records deleted, excluding them from reads and searches but leaving the entries in the file.

Has anyone out there failed for taking this approach or feel that this is a contravention of the spec?
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Matthew. Welcome to JavaRanch!

Well champ, the thing is, the "must" is in the interface implementation. You must implement the interface you received "as is", without changing it.

If things didn't change, a feature of deleation is not mandatory to be implemented (at least it wasn't in the old Sun days), but you must implement the delete method in your class that implements the interface that was provided to you. In fact, I'd advise you not to offer such a thing in your GUI if it isn't mandatory, because you won't be given extra points for doing things that are not required, and worse, you may lose points.

Now, are you using a memory cache? How do you commit the changes to the .db file? In this case, you would only need to mark the file as deleted (there's a special flag for it, which you can find in your instructions) when you commit the changes.
 
Matthew Melvin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roberto,

I'm using a memory cache with a thread to persist the db once a minute and a shut down hook. At present I mark my in memory objects as deleted and then write them back into the file with the deleted flag set to true. So the interface is implemented and it hasn't been changed. I have therefore fully complied with the specification in that sense. However, my deleteRecord method does not make the record number and the associated disk space available for reuse.

My view is that the comments in the interface do not constitute part of the interface. If there were specifics about what implementations need to do then they should be in javadoc format so that they are visible outside the source.

I'm just trying to get a concensus on whether that is a fair standpoint or whether I'm being naive.


 
Roel De Nijs
Sheriff
Posts: 10603
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not reusing deleted entries is not a must requirement, so your algorithm is just fine. Nothing to worry about: you can mark this issue as resolved and just continue with the next item on your to-do list
 
Matthew Melvin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew, just make sure that reusing deleted entries is not a must. If not, then you're fine.
 
Roel De Nijs
Sheriff
Posts: 10603
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:Matthew, just make sure that reusing deleted entries is not a must. If not, then you're fine.


The comment from my interface (I took the certification in 1st half of 2009):


So I think it's safe to say that nothing has changed in these 3 years many people passed in these years without reusing deleted entries.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic