Hi guys. Have a quick question.
Please give me a few thoughts.
I have used a three-tier approach (I think
, with the find and book methods in my DBClient interface implemented in my DBClientImpl class on the server side.
Hence, my locking / unlocking is done only by the book method on the server side.
I have also decided to allow a booking to be over written by a new booking. My book method has a boolean overwrite flag to indicate whether a booking must be overwritten if it is already booked.
But now, on the GUI side, what I have done so far:
When book is clicked, I first try to book without overwriting. If it works, all's fine. But if it returns false, then the contractor is already booked.
So, at this point I retrieve the latest copy of the record from the DB and tell the user who has booked the contractor already, and ask them whether they want to overwrite it.
They choose no. All's fine.
They choose yes, and the book is performed, overwriting anything that was there already.
However, this doesn't seem right to me after I reviewed it, because, the booking call to the DBClientImpl is autonomous. (Lock, book, unlock). So between the time I tell the user that the record is already booked by client x (the rec is not locked for this), and the time the user clicks "yes", it might have been rebooked or modified or whatever by another database client.And hence the info I showed to the user might no longer be valid.
So, should I do it like this? Or should I just let the book be overwritten without even informing the user.
What I did here seems more appropriate for client side locking. I.e. Lock, read latest rec data, book with confirmation, unlock).
Thoughts?