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

Do the unlock(int recNo) and isLocked(int recNo) methods have to throw RecordNotFoundException?

 
Mxolisi Veco
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day all.

The lock(int recNo) method throws RecordNotFoundException because before I lock a record, I first check in the database that it exists (not marked deleted). If the record is not found, I throw RecordNotFoundException.

When I unlock a record, I just remove it from the locked records map. If the record is not on that map, I just throw an IllegalArgumentException indicating that the record is not locked.

isLocked(int recNo) just checks that the record is in the locked records map. It does not check if the record exists in the databse or not.

My problem is, for isLocked(int recNo) and unlock(int recNo) methods, when should I throw RecordNotFoundException?

The way I have implemented the two methods currently is that they do not throw the RecordNotFoundException, and I have explained why in Data class source code.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mxolisi,

My unlock-method also doesn't throw a RNFE, my isLocked-method does. And in my opinion the isLocked should throw one, because it is a requirement (but not a must one):
Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.


I explained also in my choices.txt why the unlock-method (and also update and delete methods) don't throw a RNFE. So if you explained in choices.txt (which is the location where you have to explain your decisions), you'll be fine because you don't violate any must requirement.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic