// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public int [] find(String [] criteria)
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.
SCJP, SCJD, SCWCD, OCPJBCD
SCJD<br />SCJP 1.4
SCJP, SCJD, SCWCD, OCPJBCD
42
SCJP, SCJD, SCWCD, OCPJBCD
SCJP, SCJD, SCWCD, OCPJBCD
Originally posted by Mihai Radulescu:
Oliver, I think that Jeroen has right - what you do on the client side if your server crash after a while ?
...
42
But since this is such a serious Exception, I'm now considerung using an Error for this since the server (or standalone version) won't be able to kee
p running if this happens, no matter what I do.
If the server crashes that's a RuntimeException, which aren't specified in the interface (because they don't have to be).
SCJP, SCJD, SCWCD, OCPJBCD
A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is a little more efficient. Code complexity, including nesting depth, argument passing, and the number of classes and interfaces, should be reasonable.
a reasonable application should not try to catch
hd access errors on the server side
As for the question of RTE vs checked, I'm all in favor of checked exceptions normally, but the DBMain interface doesn't allow for additional Exceptions other than RecordNotFoundException and DuplicateKeyException, so a checked exception is not really a viable option when you encounter an IOException (other than EOFException, of course).
SCJP, SCJD, SCWCD, OCPJBCD
42
a runtime exception is the only alternative.
SCJP, SCJD, SCWCD, OCPJBCD
SCJD<br />SCJP 1.4
SCJP, OCMJD, OCMJEA
Originally posted by Mihai Radulescu:
Jeroen,
I think that you are wrong(thre are at least 7 alternatives).
How about exception chaining ? The interafce remains intact and you follow the
requirement also.
42
You still can't throw a checked exception other than the declared one(s) from a class deriving from the DB interface.
To do exception chaining you'd have to do just that unless the wrapping exception were an unchecked exception which brings you right back to what I propose.
SCJP, SCJD, SCWCD, OCPJBCD
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |