• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic