Hello everyone. My assignment is the B&S Contractors. The DB interface defines an API whereby a lock cookie is required for update/delete, etc. However, in my current implementation I do not use the lock cookie to check that a particular client has locked a particular record. Instead, I use the reference to the client (Data.this) as a key in a WeakHashMap to determine whether this is the same client that actually locked a particular record. I obviously intend to document this decision not to use the lock cookie as a value to determine the identity of a client in my design document. The reason why I have done it this way is that storing the cookie as the key in the WeakHashMap would not enable me to determine whether the client has crashed or not. Can you please tell me whether what I am doing is wrong and whether Sun will think that I have not adhered to the requirements by not using lock cookie as they possible intended for it to be used? Thank you
Hi Oli, I would recommend against this. In the real world, you would be able to go back to your project manager or architect or client and talk through this issue, explaining why your concept is better. But in this case, we do not have that luxury - we have been given instructions, and should follow them. You might get lucky and have an examiner who agrees with your reasoning (there have been cases in the past where people have deviated wildly from the specifications and passed). Or you might get an examiner like Terry got who decides that every comment (no matter how minor) in your specification must be adhered to. Do you really want to risk having a perfect solution failed on a technicality?
The reason why I have done it this way is that storing the cookie as the key in the WeakHashMap would not enable me to determine whether the client has crashed or not.
In my opinion, this is a dangerous argument to make:
You are deviating from the specifications in order to implement something that is not a requirement.
If you really want to handle client crashes, there are other ways of doing it which do not require you to violate the specification. For example: using the Unreferenced interface to find out when you client has crashed.