• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Schema handling

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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?

Thanks,
Matt
 
Matthew Undy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Can anyone see any problems with this approach?



Thanks,
Matt
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Marcelo.
 
reply
    Bookmark Topic Watch Topic
  • New Topic