aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes last one gets the lock gets the contractor? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "last one gets the lock gets the contractor?" Watch "last one gets the lock gets the contractor?" New topic
Author

last one gets the lock gets the contractor?

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 137
Hi,

About the B&S assignment, but should apply to other assignment as well.

Thinking about the DBMain interface and locking solution, I am not sure how to implement that once a record is booked by one CSR A, it cannot be booked by another CSR B, but CSR A can still update it.

I have seen people simply make sure that locking is implemented correctly and allows update (and get good marks), thus the last CSR gets the lock is the one gets the contractor, this is, however, counter-intuitive. As in real life, the first one gets the lock is the one gets the contractor.

Any one has experience on this, i.e., any deduction for the above approach?

I wonder if it is worth the effort to implement the assignment that is correct in the real life, or just implement to the spec., even though that is not a real app. would work.

Thanks.
Yan
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I would think that you would have code in your booking method, to make sure that the contractor you are trying to book is not already booked.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Mark Spritzler:
I would think that you would have code in your booking method, to make sure that the contractor you are trying to book is not already booked.

Mark


That's what I do, the sequence is {lock, read, check, (if good update), unlock}. This way if the record has been booked, changed or deleted the booking will fail. My book, update and delete business methods insist that the record read after locking must match the one pulled out of the table. If the records don't match I inform the user and give them the choice to refresh the record or the table.
Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 137
How would your solution allow a CSR to unbook a record which he has just booked (e.g., may be he entered the wrong customer id, etc.)?

Yan
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Yan Zhou:
How would your solution allow a CSR to unbook a record which he has just booked (e.g., may be he entered the wrong customer id, etc.)?

Yan


Any action by the CSR is reflected in the table when it completes, so the record used to unbook would be up to date. Also any time the system reads a record it updates that record in the table. So if it was out of date, simply retrying the command is likely to work. Note that unbooking is not a requirement.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: last one gets the lock gets the contractor?