This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I have the URLyBIRD assigment. I want to be able to find the first record number in the database that can be used for a new record. My idea is something like this:
Iterate through each record number using read() until a RecordNotFoundException is encountered. Then return the record number that caused the exception. Is it bad practice to write a method in this way so that an exception is always thrown? What might be a better strategy? The reason I wanted to do it like this is so I can reuse my read method.
The RecordNotFoundException can be thrown for several reasons, one the record number to read does not exist, or the record that is trying to be read has been deleted, also your reading a lot of records, when all you really want to do is read a short. You may want to consider doing something along the lines of the below...