Very interesting discussion guys thanks for stimulating my brain.
I would like to make a few comments about my implementation, may be it beings up new ideas or maybe it exposes some holes in my implementation.
I have fully implemented add() [createRecord() in my assignment], I have introduced a new method called lockNewRecord() which is internally used by the implementation class to generate the next available record number and lock it for record creation. This way no other creation can interfere with a particular record creation. Although the GUI doesnot use this method but SUN SPEC says we have to implement it so I did.
I have not implemented the file level code in the Data class itself. I have a DataHelper class which has the low level code for everything, and then the Data class calls the methods from this class. Also all Record Locking code lies in the LockManager class and the Data class delegates locking to LockManager class. The reason for this design is that I do not want the Data class to have too much code, whic will create difficulty in maintenance, and also OOAD techniques support seperation of functionality into cohesive units [I got a 97 is SCEA
, but am unsure of my approach here since sun instructions are rather vague ].
Although I am a bit doubtfull about not using lock unlock functionality in the local mode !!! If you think from a futuristic point of view, any functionality addition on the server side will have a big problem if we do not use locking. In the future we may need to henhance our design for various reasons [after all we all implementing a database syste !!!] we may need parallel implementation of things which may screw up due to lack of locking ??? Does my reasoning sound overkill.
In locks I define a lock with a record number and a timestamp and is stored in the hashtable with a key = a very unique cookie generated from a helper class. I can always enhance lock class to include table names to provide acces to multiple tables, so my design is okay as far as future enhancement is concerned ...Any comments here ???
I will write more as more issues cross my mind.
-Sharma