• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RecordNotFoundException in unlock method in Data class

 
Sergey Bylokhov
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
Due some problems with assignments upload. I have a few additional days=)))

My DBMain interface have signature for unlock method


My Data class implement DBMain interface. And in Data implementation I do not throw RecordNotFoundException because its not necessary and I describe it in me choices.txt.
But i have a questions Should I change signature in the Data class to



Or should I set it the same DBMain.



Thanks for help.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Sergey!

Should I change signature in the Data class to



Or should I set it the same DBMain.



You can keep the first format. The important thing is to implement the DBMain interface.
 
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 Sergey,

For every method implementation you just need a valid method override. So the 1st signature and 2nd signature are valid overrides, so it really makes no difference which one you use. Because you should always develop against an interface instead of an implementation (and so you must catch the RNFE although your implementation class won't throw it).

And in Data implementation I do not throw RecordNotFoundException because its not necessary and I describe it in me choices.txt.
Nice I did exactly the same, I even went a little bit further. In my own custom interface (which extends DBMain) I override the unlock-method (without the throws clause). The advantage: I didn't had to catch the RNFE (which is never thrown).

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