This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null terminate fields?

 
thuy nguyen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My instruction states "All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field"

I check the example file and all the fields less than the maximum lenghts are padded with spaces at the end.

Do you guys have this problems? what do you do about this?
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hadn't much trouble with that. Clients may not be 100% sure of what they want/need, so my solution complies with both cases. Just make sure that you justify your choice and you'll be file.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I faced the same problem and I padded my strings with spaces to follow the database format. I documented it.

My thoughts were that the requirements were conflicting ("null terminated" vs "must use this database"). Since other applications are using this file, I thought I must not alter its format.

When you think requirements are conflicting, you need to make a decision and document it.

good luck
Alex
 
Sebastian Puzon
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys! According to Sun reply here they agree that we can go with padding with spaces.

But I disagree! Why? Take a look..

In real world it's quite possible that You would never get sample db file, sou You would never discover what's the content of the file.

What's most important ? To adhere to project specification. I do not care that Strings are padded with spaces, that's up to client what data is stored. All I care is db specification. So i check if in this String exist '\0' character (that's null char according to java.lang.Character javadoc', if it exist I substring accordingly.

When writing to file, String is build in byte [] table, since 0 is default value i do not need to care about terminating String.

One more thing about trim(), please keep in mind that it also removes spaces from the beginning of the string... You can argument this by "What's the sense of keeping spaces at the beginning or end?" ... well it's up to client what data is stored.

It's up to You how it'll be implemented, You must have arguments why it's implemented in specific way

[ September 15, 2008: Message edited by: Sebastian ]
[ September 15, 2008: Message edited by: Sebastian ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sebastian", please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic