This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Hard coded constants Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Hard coded constants" Watch "Hard coded constants" New topic

Hard coded constants

Jon Pengelly

Joined: Feb 09, 2004
Posts: 15
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?
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
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.

Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
It is sorta covered in the JavaRanch Style Guide.
subject: Hard coded constants
Similar Threads
Reading Record by Rec Number
NX: Bodgitt and Scarper and design/synchronization questions
Making my data aceesing class reusable.
criteriaFind().. implementation
After creating WSDL-to-JAVA what i need to do in RAD IDE?