I'd like to ask a quick question about handling the schema in the data file for the URLyBird assignment. Apologies if this has been asked before, but I could not find a clear answer when searching.
As the instructions are clear about the format of the file, can we assume that any data file must match this format and access can therefore be 'hard coded' (basically skipping the schema to access records), or must we read in the schema and use those field lengths when reading in data?
Joined: Jul 24, 2007
At the moment I am considering using a class as below to hold constants that describe the schema, for use in the file access class. A similar idea was used in the SCJD Exam with J2SE5 book, however these were placed in the DVD class, but to me it seems like information that is disconnected from the value object.
I hardcoded it. My motivation was: the database file is unlikely to change. And if they are rebuilding the database anyway, then I'd strongly recommend a complete rebuilt or better, a switch to a relational database.
I've seen lots of people pass hardcoding it. [ July 24, 2007: Message edited by: rinke hoekstra ]
I think hardcoding is acceptable and is a good solution, because the file are not going to change. But, I am reading the schema and storing it in a array list, because it is easier to implement, and it demands less code. for example, to write all fields of a record to the file I just need the folowing code:
See, with just a few lines all the fields are saved. Using constants, you need to use each one of them, and the code will have more lines.
SCJP5(93%), SCJD(in progress...), SCEA(not started yet...)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com