• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLYBird DBMain basic question

 
Mo Negargar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Looking at my assignment, UrlyBird 1.3.2, DBMain interface contains the following comment:

public interface DBMain {
// Reads a record from the file. Returns an array where each
// element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;

// rest of the code
}

The way I am thinking about doing data reads is to read all the data into an ArrayList at first use and then use the read method of the above interface to read from the ArrayList. The comment however, states that this method "Reads a record from the file". Well, technically speaking I am not reading from the file but from the memory. Is this likely to cause a problem?

Thanks in advance

Mo.
 
Martin Sturzenhecker
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mo,

your approach should not be a problem as long as the effect of what is done makes it look as if the record were read from the file.

This means you have to ensure that your "record cache" keeps somehow in sync with the data file.

As far as I saw a couple of other threads in the forum deal with record caches as you describe it.

I for my part will not use a cache and read/write the file instead.

regards
-martin
 
hassan kalaldeh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Mo,

if u ask me i prefer to deal with file, cuz it hard to keep the memory and file as synchronous , so i think it's more effecient to use the file

but i think lot of people are using the memory approach here !!
 
Marcio Aun Migueis
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mo,

Using a cache is a good idea but could open new doors for bugs. So, I suggest you to avoid the cache solution for this assignment.

regards

M�rcio
[ December 26, 2005: Message edited by: Marcio Aun Migueis ]
 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I believe it depends on choice! I am using a cache cause i believe it would make it easier for me to deal with it than deal with the actual file! Well i suppose keeping it in sync is always the problem! Just remember to update the actual file before updating the cache! As long as you can defend your self in using a cache, you can go on ahead! Dont use a cache cause your friend down the road doing the SCJD is using one ! Anyways have fun!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic