• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to interpret exceptions in the spec

 
Dora Gal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am almost ready with the application but I still have some questions about the spec (UrlyBird 1.3.3), especially about the checked exceptions defined in the DBMain class.

When to throw a RecordNotFoundException in the

method? When there is no record in the database which matches the criteria? Why don't we simly return an empty array then?

The other question of mine is quite similar:

In my data access system it never happens that a key / record number gets duplicated.

The reason why it makes me worried is that this misunderstanding might result in an automatic failure (their unit test may fail if the expected exception is not thrown).

Thanks in advance,
Dori
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dora:
Why don't we simly return an empty array then?

It is the same thning. Just catch the exception and interpert as an empty array. It is matter of tase and design, however we don't have the lexury of writing our own specifications, so we have to adhere to what is given to us.

In my data access system it never happens that a key / record number gets duplicated.

The reason why it makes me worried is that this misunderstanding might result in an automatic failure (their unit test may fail if the expected exception is not thrown).

I had a similar issue. Just document the behaivior of your method, and justify why the exception will never be thrown. I think you will be fine.
 
Anton Golovin
Ranch Hand
Posts: 530
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you feel so bad about it, maybe you should throw it - just make sure your code's path of control never throws it
[ July 30, 2004: Message edited by: Anton Golovin ]
 
Dora Gal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic