File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on new version assignment

 
zhang bo
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 442
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To frank sun and Ta Ri Ki Sun
Thx a lot!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic