Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No RecordNotFoundException would be thrown in the body of Data.unlock() method

 
Hu Yong Jun
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hu Yong Jun:
A thread deletes a record. It must unlock the lock whose record does not exist. So no RecordNotFoundException would be thrown in the body of Data.unlock() method. Is it correct?


It could be thrown with this check:

1) !Is the record locked? AND (&) 2) !Does the record exist?
 
Omar Kalaldeh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Database interface says unLock method could throw RecordNotFoundException but that doesn�t mean you have to throw it in your implementation.

For me it is not logical to throw that exceptions, because when ever I locked a record no way one can deleted (unless I have a bug in me code), and by that the only two situations a RecordNotFoundException will be throw is:
  • You locked a record, you deleted it, you tried to unlock.
  • There is a Bug in your locking.


  • So my conclusion you don�t have to throw that exception.
    [ October 12, 2004: Message edited by: Omar Kalaldeh ]
     
    Rob Shields
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    For me it is not logical to throw that exceptions, because when ever I locked a record no way one can deleted


    Hi

    Are you saying that you're not locking a record before you delete it?

    In the version of the assignment I have, the delete method takes a lockCookie param, so a record needs to be locked to delete it.



    Is that the same problem you're having, Hu Yong Jun?

    Rob
     
    Omar Kalaldeh
    Ranch Hand
    Posts: 58
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Rob.

    Are you saying that you're not locking a record before you delete it?


    Noooooooooooooooooooo,

    you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method
     
    Rob Shields
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Noooooooooooooooooooo,

    you should Lock\Unlock records in deleting just like any other database method, what I was saying there is no need to throw RecordNotFoundException in unLock method


    Righty-ho, I'm glad we've got that cleared up

    The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.
     
    Omar Kalaldeh
    Ranch Hand
    Posts: 58
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The only thing I'm concerned about is why would the delete method be declared to throw RecordNotFoundException if it's never going to be thrown? Do you think there's a chance of being marked down for not throwing it? After all, it's no much trouble to catch and ignore it if you have just deleted the record.


    Again I am talking about unLock method not delete method.

    and as for getting marked down I don't think so as long as you state at your design choices document.
     
    Rob Shields
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Omar

    Again I am talking about unLock method not delete method.


    Sorry, yes, I meant unlock, not delete.

    $myPost =~ s/delete method/unlock method/;

    Rob
    [ October 12, 2004: Message edited by: Rob Shields ]
     
    Inuka Vincit
    Ranch Hand
    Posts: 175
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    In my code I just to see if its a valid record number(using the total number of records including deleted), and not if the record was deleted(the record exists although its deleted). Although this sittuation is impossible it can be used to detect bugs in the upper layer code.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic