• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deleting Records

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic