• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

zero-based or one-based records

 
Sven Mari�n
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in dubio about wether my field and record numbering should be zero-based (as arrays are) or one-based (as jdbc is). Anyone got any thoughts about this ?

Thanks.
 
Mogens Nidding
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's is a matter of taste. Nonetheless, I would recommend 0-based for two reasons:

  • 0-based will make your arithmetics simpler (you'll avoid something like recordPos = recordLength * (recordNumber - 1) + offset)
  • I think 0-based is "most" standard since it is used for arrays and the list/vector classes, which are used everywhere by everyone


  • [ October 14, 2004: Message edited by: Nicky Bodentien ]
     
    Sven Mari�n
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well, I was only considering one-based to be equal with the JDBC way of saying 'this is the first record' or 'the first field'. However, I can compensate it with constant representations of the fieldnumbering in my specialized Record class. Thinking about specialization by the way, how far would you go in specializing the Record/Field representation? I mean, me myself created Record and Field classes containing the data values as Objects opposed to the Data class representation, which uses String for every value. And from that class I'm thinking about creating a BNSRecord containing the correct fieldnames and values perhaps stored in a Hashmap...
     
    Anton Golovin
    Ranch Hand
    Posts: 527
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Sven Mari�n:
    I'm in dubio about wether my field and record numbering should be zero-based (as arrays are) or one-based (as jdbc is). Anyone got any thoughts about this ?

    Thanks.


    Hi, Swen. I would make them zero-based just for convenience; that's the way I implemented them in my own project. It's better to keep track of data structures that way, too, and that's an added bonus.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic