File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Deleting Records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Deleting Records" Watch "Deleting Records" New topic
Author

Deleting Records

Matthew Melvin
Greenhorn

Joined: Mar 08, 2012
Posts: 3
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

Joined: Dec 28, 2007
Posts: 2268
    
    3

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.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Matthew Melvin
Greenhorn

Joined: Mar 08, 2012
Posts: 3
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
Bartender

Joined: Jul 19, 2004
Posts: 5608
    
  15

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


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Matthew Melvin
Greenhorn

Joined: Mar 08, 2012
Posts: 3
Thank you
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Matthew, just make sure that reusing deleted entries is not a must. If not, then you're fine.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5608
    
  15

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.
 
 
subject: Deleting Records