This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

create, delete and locking

 
Keith Jones
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the specification of the lock method this method



Locks a record so that it can only be updated or deleted by this client.



In the case of delete, does this mean that we do the following:



Problem is if we lock, then delete then attempt to unlock then we should get a RecordNotFoundException in the unlock method as that is what the unlock method should return for a record that is marked as deleted. Anyone have any ideas as to how this should be written?
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could drop the exception from the unlock method in your data class.
 
Keith Jones
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely that's not possible since the specifcation for the unlock method says that we must throw an exception if we try to unlock a deleted record.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mine doesn't state under which conditions RecordNotFoundException is thrown so I've decided to never throw it in unlock().
Would be pointless to throw it there anyway, you're trying to get rid of something that's not there, fine by me
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Jones:
Surely that's not possible since the specification for the unlock method says that we must throw an exception if we try to unlock a deleted record.


I think that it is an easily defendable option to take with regards to this issue as is dropping DuplicateKeyException in the create method. If the RecordNotFound exception is thrown by the unlock method before the record is unlocked then the record will never be unlocked. But if you unlock the record before checking it exists then whats was the point of the check in the first place?

Mark.
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say if you are deleting record which is already make deleted (check using flag) then throw RecordNotFoundException since my assignment says clearly

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.


[ February 12, 2007: Message edited by: Ken Boyd ]
[ February 12, 2007: Message edited by: Ken Boyd ]
 
Lucy Hummel
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

There exists also a different opinion than Ken's one.

If a record should be delete and it is already deleted, then the goal of deletion is already achieved in the client's view point. So that means for the client point of view, do not throw any exception.

Anyway, if in your assignment is mentioned to throw such an exception, then the client want such an exception and you have to throw it.

Br, Lucy
 
Vincent Li
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Jones:
Surely that's not possible since the specifcation for the unlock method says that we must throw an exception if we try to unlock a deleted record.


Surely that can't be in your spec? This is what mine look like:



It only throws the SecurityException. There is also nothing that says I can't unlock a deleted record. You could prevent "locking" of a deleted record, but once it's locked, then you don't have to worry about its existence to unlock.

-- Vince
SJCP(1.4),SCWCD(1.4), SCJD(almost there)
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method signature is correct alright here is mine from the urlybird project.


I just dropped the Exception it in my Data implementation of unlock and justified it in my choices.txt by saying it made no sense .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic