Hi,
I have specified a locking contract for anybody using my Data class. It is like many people's implementations :
Lock record
Do whatever you want to the record
Unlock record
I am happy with this approach even though there is the flaw that we cannot guarantee a programmer using Data will follow this contract. I was just going to document this and acknowledge the flaw.
However, after thinking about this today I think that I should add a check to the update and delete methods to ensure that this record is in the lockedRecords map and that the owner of this record is the current
thread.
This is pretty good because it means that even though we have specified the lock contract we are still protecting the database from updates and deletes without having locked the record.
And so my questions are:
Is this what everyone else is doing and it is the case that I was just a bit slow on the uptake with this one?
Or maybe I haven't thought this one through and people can spot a flaw in this idea?
Thanks for any comments,
Jonathan