• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB interface VS Data class

 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What do you guys think of this:

+------------------
| DB <<interface>>
+==================
+------------------
| read() throws OneException
+---------------------------
^
|
|
+------
| Data
+======
+------
| read() throws OneException, ARuntimeException
+----------------------------------------------

The Question is: Can I declare that Data is throwing a RuntimeException in its public interface even though the supplied DB interface doesn't? OR should I just leave the declaration out of the Data class (i'm throwing the RuntimeException anyway, to handle some errors that occur within the Data class).

[ May 13, 2007: Message edited by: Bod Toki ]
[ May 13, 2007: Message edited by: Bod Toki ]
 
David A. Scott
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're not "breaking" the interface contract by adding a RuntimeException I don't think there's a problem.

And declaring it in Data.java is good manners for any (theoretical) client programmers using your class.
[ May 14, 2007: Message edited by: David A. Scott ]
 
Lucy Hummel
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I totally agree that is quite okay to throw a RuntimeException.

For example the topic URLyBird - How to handle IOExceptio discussed the topic already.

I think you will find more topics related to your question, if you use the search feature of the JavaRanch.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic