I want to implement locking like this: lock record, see if it has changed, update record, unlock record

However, in order to see if the record has changed since the user last refreshed his view, I need the client to pass his view of the record in addition to his changes to the record. The above interface does not allow for the client view of the record to be passed to the updateRecordMethod. How should I approach this? Should I provide an empty implementation of the method? Should I label it as deprecated and suggest using a method such as updateRecordSafe instead? Thanks all.

Originally posted by Anthony Watson: Should I provide an empty implementation of the method? Should I label it as deprecated and suggest using a method such as updateRecordSafe instead?

Antony, Both the above options are risky.

My instructions say that the functionality of the update() method is to modify the fields of the record in the database only, if the cookie supplied is the cookie that was used to lock the record before.

Which means that when the update() method is called, the record is already in a locked state by the client.

Probably your instructions also may mean the same thing.

"lock record, see if it has changed, update record, unlock record"... - could be the list of methods called in the booking use case and not for the update() method in the Data() class. So I would say....

for the update() method in the Data() class: "do recNo validation, do cookie validation, update the record."

Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327

posted May 27, 2004 17:25:00

0

I'm retarded...I asked my questions as though the client was going to call the update method directly. Obviously, the client should go through some sort of adapter that encapsulates all the read, lock, update, unlock functionality.

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066

posted May 28, 2004 02:04:00

0

Originally posted by Anthony Watson: I asked my questions as though the client was going to call the update method directly. Obviously, the client should go through some sort of adapter that encapsulates all the read, lock, update, unlock functionality.

Yes. You also have an option of implementing it either on the client side(2-tier approach) or server side(3-tier approach).