Hi,
1) In most places of the given code, Database Exception is thrown for obvious reasons. For example, invariant() throws because the database is not in a readable order, add() throws for attempting to duplicate keys, the data to be added in db is insufficient.
These conditions are very much expected and not exceptional. Hence, can they be checked for and returned as boolean �false� to the caller? But I am puzzled on how to send the caller the reason on why the operation was failed. I arrived to this decision of limiting Exception only to unexpected situations based on this article,
http://www.javaworld.com/javaworld/jw-08-2000/jw-0818-exceptions-p2.html In that case, what situations and how situations can be considered �Exception� ?
2) In the archives, there were suggestions for using Synchronized blocks over entire method synchronization. When I tried doing that, I lose safety. I feel we cannot use sync blocks in this project. For example,
When control enters the synchronized block, no other
thread is allowed to enter inside the block, but the 'DataInfo newData' of the method signature can be accessed by the next arriving thread. This argument, used inside the block could then get corrupted, since work is going on inside the block. Hence, can we conclude that we cannot use blocks in our project and to assure safety, the entire method has to be synced?
3) Methods �size�, �seek� resemble some of the methods of
Java API. Can this be a reason for it to be renamed?
4) I am not bringing the Connection and Data interfaces under the same interface. Decoupling them will help Connection to be independent of any Data interfaces. If another Data interface comes up with different signatures, 2 people are not affected (Connection and the Client side interface) , only the implementation of Connection would need modification. Is this a good idea?
5) Lock method specifies that �No timeouts is specified for this�. So should we not implement timeouts. Is�nt not specifying timeout gives rise to locking forever?
6) Can the primary key of the db be sorted through Map? I wish to maintain a Map of Primary keys of LiveRecords of the db. It would help is standard easy search.
7) Some people in archives say of using many Connection objects for many clients. Since we have to provide 'stub' of one implementation to each of the client, how can we provide many Connection objects. I was planning to have one Connection implementation and having its methods synchronized. Is this direction wrong?
Please give your suggestions. My voucher deadline for submission of exam is on or before 31 dec 02.
Thanks in advance,
Rajesh