Hi Phil,
Originally posted by Philippe Maquet:
Justifications of solution 2 :
The RecordNotFoundException in the find() throws clause in the interface suggests that it's the way Sun expects you to implement the method in Data. I don't see any other argument.
For the client software required for this project, you are (probably) correct - handling reception of an empty array
might be easier than handling an exception. But that depends on how the client is written, and what it considers "proper" response to either event.
If the proper response is just to display an empty table, then certainly it will be easier. No handling required.
But if you wanted to display a dialog box informing the user that the search failed, then catching an exception is the
preferred way of doing things. Checking return values is very C/C++.
And for other software that might use the same database, displaying an empty table might not be the correct way to do things - say you are printing reports on an expensive / highly used printer: do you really want to print an empty report? In which case I go back to my earlier statement that catching an exception is a more "Java" way of doing things.
Originally posted by Philippe Maquet:
I do prefer solution 1 but you'll have to make the choice by yourself ...
Given that Sun have specified the exception in the method signature, I think it is obvious what they want
Regards, Andrew