Hi Shan
It is for sure that in remote mode write lock must be implemented. What about in local mode?
I think the answer depends on where your locking code is, in both the GUI and in the Database.
From the database perspective, you can code the locking into the suncertify.db.data class itself, or you could code it into the classes that handle network connectivity.
Likewise on the GUI side, many people seem to be building a connection factory to handle the local vs remote technical details. You can put the locking code in the connection factory's network specific code (in which case the GUI only calls an "updateDatabase" method, and the network version of the updateDatabase method handles the locking and unlocking of the record), or you can put the locking code into the GUI itself (so it calls "lock", "updateDatabase", and "unlock").
Now - in the case where your locking code is in the networking section of the database, and in the networking section of the connection factory, you
could have the local mode do no locking.
I think that the same
might apply if you have your locking code is in the suncertify.db.data section of the database, and in the networking section of the connection factory.
However, if you have the locking code in the GUI application iteself, then you really want to do locking in local mode as well, because if you dont, then you have different GUI code for local vs remote mode, and that should be transparent to the GUI. (Not to mention the problem for anyone maintaining your code (think examiner), where they have to look at two sections of code that are supposed to be doing the same thing.
Now having said all that,
my personal belief is that locking should be done whether local or remote.
My reason is that locking the record is a blocking method. Therefore I want to give the user feedback that I am attempting to lock the record, I am updating the record, I am unlocking the record. If I dont do that, then the user may think the application has crashed when it is attempting to get a lock.
If the locking code is all done on the database side (no code at all on the client side), then I cannot do this.
If the locking code is in the network specific code, then the user is going to get different messages depending on which mode they are in (unless you fake the messages) - I would prefer to have it such that the user is unaware of which mode they are in.
Hope this gives you some things to think about.
Rememer there is no one right way, so other people may disagree with me, and you are free to choose your own way.
Regards, Andrew