Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes cookies/deleting 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 "cookies/deleting" Watch "cookies/deleting" New topic
Author

cookies/deleting

Laura Williamson
Ranch Hand

Joined: Apr 28, 2004
Posts: 44
and how do i decide what value to use as a cookie?

- also when a record is deleted from the file i set ValidByte to 0XFF.

BUT what to do with record in the List I keep in memory - set first elem in data to 0XFF or set elem to null, or remove from list?

thanks
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi Laura:
As I understand form the project specification, we should use the original magic cookie value, which is supplied in the original .db file, to validate any other .db files.
If you are keeing all the records in the memory, I recommend you remove the deleted files. Otherwise, your program will waste memory resources.


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Richard Everhart
Ranch Hand

Joined: Nov 19, 2003
Posts: 54
Hi Laura,

I'm not sure which 'cookie' you're referring to.

If you are referring to the lock cookie then there have been several threads on this topic that you should find helpful. I am just using an integer. As for the 'magic cookie' value, this value is siimply part of the .db file (the first value in the file actually) and identifies it as such.

As for deleting, my instructions say that I can reuse deleted records. So, when a record is to be deleted I set its flag to '1', or 0xFF as you say, but I don't remove it. Instead, the next time I need to create a record I reuse the first deleted record I find in the database. If there are not deleted records, then I actually add a new record when I need to create one.


Rich
Laura Williamson
Ranch Hand

Joined: Apr 28, 2004
Posts: 44
apols - i'm talking about lockCookie. but the int used must be unique to each client no? so I' m wondering about that...will search on lock cookie.
Laura Williamson
Ranch Hand

Joined: Apr 28, 2004
Posts: 44
ok i got it - read old threads, no probs, thanks
Laura Williamson
Ranch Hand

Joined: Apr 28, 2004
Posts: 44
RE " as for deleting, my instructions say that I can reuse deleted records. So, when a record is to be deleted I set its flag to '1', or 0xFF as you say, but I don't remove it. Instead, the next time I need to create a record I reuse the first deleted record I find in the database. If there are not deleted records, then I actually add a new record when I need to create one"

-- you are definitely talking the list in memory here rather than the DB File - right? I do that in the DB file but wondering if that is the best approach for the list of record I keep in memory
Richard Everhart
Ranch Hand

Joined: Nov 19, 2003
Posts: 54
-- you are definitely talking the list in memory here rather than the DB File - right? I do that in the DB file but wondering if that is the best approach for the list of record I keep in memory


Yes, I am referring to the db file, but I don't actually remove the record from the memory cache after I've set it to be deleted in the db file. Instead, I just set the cached record to deleted.

Rich
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cookies/deleting