Matthew Blaise

Greenhorn
+ Follow
since Jul 03, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Matthew Blaise

One note though...readInt() would not work and throw an exception if it reaches end-of-file before reading the fourth byte.
Blaise
"numeric" is not defined exactly, so I tried to narrow the specification in my documentation:

The primitive type "int" in java is defined as a 4 byte signed integer. The "readInt()" declared by the DataInputStream interface and defined by RandomAccessFile should read the next four bytes from your file and put them in an int to return to you. So, yes, raf.readInt() should always work.
If you wanted to construct an int from 4 bytes you'll have to use some shifts and masks. Make sure you conform to one byte order, "big-endian".

Does this help?
Blaise
Thanks Phil. That's exactly the kind of response I'm looking for.
If anyone else had to design a database, please comment about your decision to add extra features or not. Did anyone make a simpler database, designed only to support sun's requirements?
Blaise
Calling all Contractors!
It seems that the backend of the database can be implemented in almost any conceivable way, as long as it can be accessed with an object that implements the DBAccess interface. I'm just wondering if anyone has any more generic designs for this or is everyone just creating a "dummy" database that just implements the interface directly. This problem has been plaguing me for a while now. If I get carried away, I'll end up making a "real" database which will take forever (and be really hard). However if I make a "dummy" it seems like I should be doing more to support any future development or reuse. The only clue I have is in the instructions.
"The IT director does not anticipate much reuse of the first Java technology system, but intends to user that system as a learning exercise before going on to a web based system."
What do you think? If you have a more complex design please tell a little about it.
Blaise
I'm not sure why you are using a FileChannel. I'm not too familiar with them so please let me know if there is some advantage to your method.
I'm just using the RandomAccessFile.
e.g.
RandomAccessFile raf = new RandomAccessFile("dbfile", "r");
int magicCookie = raf.readInt();
Anything wrong with this?
Blaise
...to answer your question more specifically:
1. SHOULD we add javadoc comments to the interface file?
No. I doubt you will be penalized if you leave the file as-is.
2. Is this an "untouchable file"?
No. I'm sure you can do anything I mentioned in the previous reply without any problems.
I'm sure you can do whatever you like to the interface file as far as commenting/layout is concerned. The important thing is that the actual code should not change at all. I really don't think the compiler cares about javadoc, comments, whitespace, or order of function declaration. So go crazy. Just make sure that you can swap the original in place of your edited one with no problems.
Blaise
Hi Guido.
So you think that they will take your design into account when testing? i.e. pass the necessary File object?
Blaise.
Also, does anyone's Data class use other classes besides a LockManager class and a RandomAccessFile? I'm thinking of using some kind of storage strategy abstract class and subclassing to implement the methods of accessing tables and having that class return a wrapper representing a table. Any comments? Am I crazy?
Thanx.
Blaise
Hello All.
My specs tell me:
"Your data access class must be called 'Data.java'...and implement the following interface:"
It lists the DBAccess interface after this. This looks like it will be the class that the testers will use to run some automatic tests. When I ask myself how they will do that automatically I am led to believe that they will have a test program that creates an instance of our Data class and go from there.
Is this a correct assumption? If so, the Data class must be able to be initiated properly with a "no-arg" constructor and many properties will either have to be hard-coded or looked up in a suncertify.properties file.
So, I guess the real question is: does anyone know if the testers make any attempt to use your Data class as you design it or do they just plug the class in to their code blindly.
Thanx
Blaise