• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DB interface VS Data class

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic