• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hard coded constants

 
Jon Pengelly
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a helper class (Contractor) that I use in my Data class and my Adapter/Bridge class. It is used to populate my record cache and also holds matching methods for the criteria match and things like that.
However, I have the following constants defined in this class : NUMBER_OF_RECORD_FIELDS, NAME_INDEX, LOCATION_INDEX, etc...
This information is provided in the database file header. Thus, should I be using those values rather than these constants?
The reason that I went for the constants in the first place is because if the data file was changed this contractor class would have to be updated anyway to include the changes (a new field for example), and so the contractor class would need to be updated anyway.
What do people think of this decision? What about the decision to have a helper class in the first place?
Jonathan
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably nicer to have it dynamically read in the real world. But, as you say, then that class would have to be updated anyway if the data changes.
Flexable data structures is probably out of scope for this asignment. Fun though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic