kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
But the problem is that before the lockRecord completes an exception may occur (like RecordNotFoundException).
Thus I think to check if cookie has got a value different to zero is more sure.
There is a 3rd solution, though, and I think it is safer and easier to use as well. Writing unlock in such a way that it simply returns in case the record to unlock is not locked.
2. It's better to do both as you do in your second implementation IMO. You have your Data instance at hand, so the additional check doesn't cost you anything. What I don't know is which method the second code snippet is extracted from. What are you doing there exactly?
Sounds reasonnable, doesn't it?
kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
My only argumentation PRO my solution is "If validation change (48h->72h)there is no reason to stop the server".
Much more indeed! But I would have kept the previous snippet, just replacing the "return" statements by a your exception: remember that in your design, the fastest access (by key) is performed on the data instance.
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|