I have the B&S 2.1.3. assigment that uses locking with cookies.
I liked Marcelo's solution Locking strategy with singleton because it was easy to understand and simple. This aproach was also what i had in mind before reading the Denny's DVDs example. I was implementing a solution similar to yours but i found a good reason not to do so.
The specifications of my lock method: Locks a record so that it can only be updated or deleted by this client. ... If the specified record is already locked by a different client ... waits until the record is unlocked.
the expresions "by this client" instead of "the client who owns the cookie" , or "by a different client" instead of "with a different cookie" is confusing for me. It seems that they whant a solution similar to Denny's DVDs in witch the "client" is passed by parameter by the DvdDatabase class.
If that's what they expect us to implement i don't understand the sense of using a cookie.
If the client must indentify itself for locking , what's the sense of obteinning a random generated coockie if we also need to store the identity of the client that locked the record?
That's because i think it's also posible to understand and replace "the client who owns the cookie" and "with a different cookie" instead "the client" and "different client" in the specifications.
would this interpretation end in a Automatic Failure ?