*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question on new version assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question on new version assignment" Watch "Question on new version assignment" New topic
Author

Question on new version assignment

zhang bo
Greenhorn

Joined: Jan 21, 2003
Posts: 4
Hi,there.
I just downloaded the new version assignment, whcih has clearly listed out the structure of db.db. And I wondered if I could define "field numbers","length of field" and "length of record"
as constant. You know, doing this will save much work. Thanks in advance!
frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
First, I don't think put those variables as constant will save much effort.
Second, I don't think it's a good idea to put them as the constant.
Frank
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
better to have a Field object that reports it position in the record, its maximum length, and its name.
As for the total length, that sounds like a different object
zhang bo
Greenhorn

Joined: Jan 21, 2003
Posts: 4
To frank sun and Ta Ri Ki Sun
Thx a lot!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
My two cents - I do think that it might be nice to define things like record lengths, record names, etc. as final, since there's no reason for these things to change once they're initialized. The trick is to make sure that they're properly initialized (by reading the DB file header) by the time the appropriate constructor or / class initializer ends. And (more annoyingly) to convince the compiler that they're really initialized. I find that if I initialize all the instance finals in the constructor, the compiler is happy - but if I try to extract this to a separate (private) method for readability, the compiler whines about blank final fields. Very annoying. So I remove the "final" while refactoring, but I'm hoping to put it back in later...


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: Question on new version assignment