• 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

B&S: Need some clarification on RecordNotFound Exception

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need some feedback from you concerning the usage of RecordNotFound Exception.

My assignment is:
-----------
public String [] read(int recNo) throws RecordNotFoundException;

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.
-----------

My question is : is it alright to throw RNFE only when a specified record does not exist and return null when is marked as deleted in the database file?

Anyone disagree ?

Regards,
James
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you want to return null in any case ? I think the specification is clear in this case: if it is marked deleted, throw RecordNotFoundException.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.
-----------

My question is : is it alright to throw RNFE only when a specified record does not exist and return null when is marked as deleted in the database file?



Hi James,

I think it is not alright. The specification is very clear that if it is marked as deleted, the exception should be thrown. Although this requirement does not use the must-word, I would not take my chances on this one if I were you.

Also, from a software engineering point of view, it seems as a bad choice to me. It does not really matter whether the record does not exist at all or is marked as deleted: bottom line is that the record is unavailable and cannot be accessed.
The situations where your code needs to make this distinction, should be handled in lower-level parts of the code; not in this interface.

Frans.
 
Do not threaten THIS beaver! Not even with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic