aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes update() what? delete() from disk or memery? 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 "update() what? delete() from disk or memery?" Watch "update() what? delete() from disk or memery?" New topic
Author

update() what? delete() from disk or memery?

Zhixiong Pan
Ranch Hand

Joined: Jan 25, 2006
Posts: 239
Hi all,
In urlyBird, I am not sure about tow methods of Data.One is update(), i want to know in what cases should call update()?The other is delete(), when called, should data is db file be removed or just the collection class in memery which store records be removed?


SCJP 1.4 SCJD
Eiji Seki
Ranch Hand

Joined: Feb 15, 2006
Posts: 88
Hmm, I don't think we can comment on that, since the methods vary. IF your update and delete methods are same as mine:

update(int recNo, String[] data)
Changes the record (replaces the record with the given record number with the one you are passing as parameter)

delete(int recNo)
Makes the record ready for reuse (mark the record with the deleted flag so create(String[]) invocations will reuse it's space).
Notice that you don't need to phisycally remove the record from the file. You just mark the space it takes as free.


SCJD URLyBird (WIP)<br />SCJP 1.5
Eiji Seki
Ranch Hand

Joined: Feb 15, 2006
Posts: 88
Of course, if you are using memory cache of the data, you need to make sure your cache reflects the changes made to the file.
OR, if that is your case, just change the memory cache and then make sure all operations are persisted when shutting down.
Kevin Conaway
Ranch Hand

Joined: Jan 27, 2006
Posts: 57
That is a design decision that can only be answered by you.

However, you really need to start searching the board for your questions before you ask them. I know its tempting to just come here and post whenever something comes to mind, but all of your questions have been answered on this board, most of them within the past few days and weeks.

You have to make some design decisions yourself.

For my commentary on your question, see this thread

Kevin
 
 
subject: update() what? delete() from disk or memery?