My first time in this forum howdy all!! I've just started with my 1.2.3 version of the URLyBIRD assignment. I've started reading the forum for hints tips an ideas. But there are so many things to concider, I'm almost afraid of starting of the wrong way, but today I finally opened eclipse and started with the data access layer. I'm just putting the data access in one class right now, till it works and refactoring it as i go along. What I was thinking was that the "server"controller class, creates one instance of the Data class. The constructor of the Data-Class opens a RA file object for file access. (and somewhere the server class calls a close for the RA file object) What i'm still not certain of is how to access the data section of the data file. First of you have to get to the data section of the db.file What would be the correct way? 1.
I've someone could give me a push in the right direction,
Regards, Hans [Andrew: broke up long lines so that this displays without requiring horizontal scrolling] [ November 13, 2003: Message edited by: Andrew Monkhouse ]
Hi Hans, Welcome to JavaRanch. Personal thoughts: your first solution is not very extensible if you ever need to add an extra field, or change the size of a field (or even work with a totally different database that has the same meta schema). In that respect, your second solution is much better. But I would probably only want to read the schema once - once you have read it the first time, you can store the size of the schema and then just skip it for future reads. I would also consider refactoring your two constructors - one could call the other. It won't make much difference with what you have now, but it might make a difference if you want to do much more in the constructors. Regards, Andrew
Also, if you Data class performs a lot of other operations such as locking, unlocking, deletes, search, find,....You may want a helper class to perform all of the actual opening, and reading of the DB file. Then have a variable in the Data class that refers to your helper class. Your Data class can still write to the DB file but it gets an instance of the DB file from the helper. When the Data class needs all of the records, it asks the helper class, when it needs to know the length of a field it asks the helper class...and so on. Your helper class will more than likely be a singleton because I am assuming your assignment deals with only one file