Hi,
Thanks very much for posting your detailed reasoning for others to learn by.
Keep in mind that I'm new to this exam (in that I keep discovering things that
I have to learn), and so my ideas may be off the mark; but, if I may, I'll state them.
Some of my comments may be vague or general or intuitive.
If it's already locked, then a dialog appears asking if the client wants to wait for the record to become available, or cancel the booking attempt and try again later.
Intuitively, this doesn't sound right. Waiting for a lock should not take overly long
(granted, "overly long" has not been defined).
First, before presenting my idea, let's consider an idea which may not be feasible:
in short: when a thread is sent to lock a record, it let's the system know who it
is and how long it has to do its job; if it has not reported back by that time
saying that it has got the lock, the Killer object interrupts the thread. This idea
is bad because if the thread is interrupted during an I/O operation, the DB file
could be corrupted and, the DB file may need to be re-opened.
However, this might be good idea, because you're only interested in catching a long
wait before the locking occurs. After the thread has the lock, it tells the Killer
object to disappear; thus, the Killer object can never kill the thread while it is
doing I/O.
Generally speaking, hopefully our systems are responsive enough so that we are
not waiting overly long for that lock.
How long can this wait be? I think the wait can be anywhere from a split-second to
eternity. I have no idea how long it's going to take the current owner of the lock
(lets call him Joe) to enter the customer ID in the book selected record dialog.
Intuitively, I don't think
you should place your application in a position where it is
dependent upon the client entering data and pressing buttons. Now you have designed
in very long locks, which is, as I heard and read recently, not appropriate. Would it be worse
if the user booked a record and you simply came back saying that record has already
been booked? In general, locks are held for short amounts of time (in computer processing
speed standards, not human reaction time standards), or so I've read recently.
Actually, would it avoid the long, potential wait if the application would not accept
any action from the user requiring a lock until the user first entered his customer
ID?
Furthermore, I have no guarantee that when the current user releases his lock on my selected record, that I will be the one to get the lock next or rather one of the other 20 users waiting for this same selected record. So it became clear to me (and perhaps only clear to me) that I really couldn't know how long a user could hold a lock.
If the locking is always done for a short duration by any given thread, then it most
probably will not take an overly large amount of time, and thus you can know,
within reason, about how long it would take to get a lock if you know other
system information (how fast RMI is, how many clients there are, how many clients
are attempting to obtain a lock on the same record).
By the way, it just occurred to me that you may have already taken and passed
the exam. If so, I guess I sound foolish. But, assuming that you have not
already taken and passed the exam, then the above are my current opinions.
"wait for lock now, or try again later" prompt
I'd never issue this prompt, since the system should be designed so that the lock
will be had in a reasonable amount of time. However, an error message may
be appropriate, and I make one up: Unable to obtain record. Perhaps this would
be due to an I/O error, and hopefully not to a programming logic error.
Summary: It's quite possible that I don't fully understand the intricacies of your
detailed design, and in this light, my ideas may not make any sense; if so,
I apologize.
Thanks,
Javini Javono
[ January 27, 2004: Message edited by: Javini Javono ]