i am writing subcontractor assignment. in this, i wrote the interface db and class data implementing this interface only.
In the book, Denny's dvd application, gui controllers method for finding with search criteria returns list of dvds. this is because this method returns list of dvd objects. but as per the interface provided, in this method for subcontractor, i am returning first int of record numbers matching search criteria and for every number read(recNo)ing record.
when i am matching say Dogs With Tools, able to filter records with this string but how should i identify these obtained records with unique record number as this field is not present in database.
when application starts record numbers will be displayed in sequence 1, 2 but this sequece get changed for new filtered results and a call to read with these new record numbers return different records.
also, how should i increment this recNo field, as of now i am hardcoding this in retrieveSubcontractor(long locationInFile) method of SubcontractorFileAccess class.
the book from andrew and terry, for this certification, has helped a lot along the way!, have never done multithreading before this book!
I think he has a little bit doubts about what he should use as a record number to identify each reacord in the database file. I would say just use a logical record number. That means the 1st record in the database has 0 as record number, the 2nd one has 1 and so on.
In your find-method you will return an array with the matching records. So if the 1st, 3rd and 4th record match the specified criteria the method will return an array containing 0, 2 and 3. So you use the record numbers corresponding to the position of the record in the database file (and NOT the record number corresponding to the position in the filter results)
i am doing the same project for my diploma, and the database file itself doesn't have a recNo field.. fields are; name, location, specialties, size, rate and owner.
i am having the same problem... i am thinking of having a "database" class that creates an instance of the database by reading the data from an inputStream... and adding the recNo field to the object at the same time... so the recNo field only exists in the application, not the database file itself... does that make any sense?...
No worries, I'm quiet familiar with the database structure, so I know the record structure has no record number You could create a value object which holds the record number and the actual data of a contractor. That makes sense, but you always have to convert between this object and a String (because all your methods use a String in its signature). And I don't know if you will use String at the client or use a value object instead, but that would result in yet again a conversion between String and object.
Joined: Apr 09, 2011
roel, now assigning record number to a subcontractor record while looping!
roberto, i am doing fine!, just stumbling sometimes between interface provided in assignment and interface present in book,
matthew, can be done this way!,