In me Design I decide to use buffering, but I have a problem with DB interface, it says in the read method comment
// Reads a record from the file. Returns an array where each // element is a record value.
Now, in read method must I read the records only from data file, and it�s not acceptable to read it from the buffer, or it is all right if I read them from my buffer.
If it the first case, then I must put another public method called readFromBuffer(), witch make Data class a little bit weird and confusing .
Or should I forget about all about buffer, and stay in safe line.
In suggestion will be helpful .
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
Joined: Apr 13, 2004
If you use a RandomAccessFile Object to read the database file, I believe it does a lot of buffering for you. So I don't think you need to worry about buffering directly.
You must be careful with buffering however when dealing with multiple threads. A lot of people do away with the buffering in the RandomAccessFile by openening in the "rwd" mode. I don't believe you need to do this unless you have more than on RandomAccessFile object (some people do have more than one for some strange reason).
Joined: Jun 08, 2004
Thank you for your suggestions.
But throw using buffering I may simplified some implementations issues such as searching, so I still need to know if implementing read method to read from buffer is a valid choice.