B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
For these methods:
public int[] find(String[] criteria)
public int create(String[] data) throws DuplicateKey
1. catch the IOException
2. log the IOException
3. return null or -1, depending on the method
4. document (for other programmers) what these return values mean
Don't Return Error Codes
This is Java. Using error codes as return values, rather than using exceptions, is a Really Bad Idea. We're pretty sure your exam assessor knows that.
Don't Return Error Codes
This is Java. Using error codes as return values, rather than using exceptions, is a Really Bad Idea. We're pretty sure your exam assessor knows that.
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
This is entirely consistant with the Java way of doing things. For example, the ArrayList.add() method returns a boolean that returns true if the add was successful. If you don't check that result, then the ArrayList.add() might quietly fail. Is that the ArrayList's fault? No, IMO, it's not. The API told you have to use the method: it's up to you to do so.
B.S. University of Wisconsin<br />SCJP 1.4 (85%)<br />SCJD 1.4 (92%) B&S Contractors
Wouldn't life be easier if we could use any checked exceptions
MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
Originally posted by Inuka Vincit:
In my implimentation I am cacheing the file. But still the Update Create Delete methods need to deal with the IOException. I am using a method similar to Matts by using unchecked exceptions, notifying the user and then exiting.
Although I was going to chanin the exceptions as RNF exceptions, I felt that it was a bad idea because any exceptions other than RNF would indicate a fatal error that you need to deal with cleanly and who ever deals with that error needs to handle it. I realy dont think using a error codes is a bad idea though. It realy depends on how you feel about the design.
Whatever path you choose be consistent, it is such PITA to use other ppls libararies that dont have consistent implementations even if they are powerful.
[ October 13, 2004: Message edited by: Inuka Vincit ]
Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
So I don't think I should chain it to a RNFEx for errors while reading bytes. Does this solution sound okay? Is it okay that I throw a RuntimeEx? Or would it be better to subclass RNFEx? And catch the IOException and rethrow an IORNFEX? Thank you!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 1.4<br />SCJD 1.4
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|