It's one of the most crucial parts of the assignment, so I'm not going to spoil the fun of all other ranchers pursuing this certification and leave this question unanswered (so they can find out themselves through logical thinking and/or testing)
I don't see how the order can cause deadlock. Both checks are carried out inside a single synchronized block of code. Failure of either check should case the method to return (by throwing an exception). So where's the possibility for deadlock?
1) Check if the record exists (throws a RecordNotFoundException)
2) Check if the record is locked (throws a SecurityException - telling the user to lock the record before carrying out the operation)
3) Check if the record is locked by the current user (throws a SecurityException - telling the user that they are trying to carry out an operation on a record that is locked by another user)
I'm thinking of this in terms of validating the arguments to my lock method. I've two arguments - record number & lock cookie. If I do (1) first then that validates the record number argument i.e. if that fails, then there's no point in checking whether that record is locked, because it doesn't exist.
subject: Order of Checks in Update & Delete methods