Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

[URLyBird] Question about data file!

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, in the instruction file I receive from Sun, I see both the field length (specified explicitly such as: name - 64, size - 4, smoking - 1), and the schema description which allows me to get the length of the field programmatically:
---------------------------
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
---------------------------

My question is that since I can determine the fields' lengths by examine the schema description, why on earth they already explicitly show me that name is of length 64, smoking is of length 1 and so on??? Should I just use one mechanism, either use constants or read the schema, to extract the fields' values and ignore the other?
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leo


The schema description vary from a file to an other - more simpe you can have different database file with different (data) scheme.
If the database format changes in the future your applcation must be flexible enought to support this changes with minimal (or preferable with none) code changing.
The docuement from sun presents the actual database form but as I said this can change in the future.

Regards Mihai
[ April 10, 2006: Message edited by: Mihai Radulescu ]
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a design decision you need to make.
Using constants is easier, but will require program changes if the database changes.
Using the schema description may allow the program to continue to work if the database changes, but such design will be complex. I said may because you have to ask yourself, would you be able to anticipate all possible database changes and properly design and code for them?
 
Leo Ho
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Mihai & Chen. I guess I would use the schema instead of the constants.

Leo
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic