• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

must recNo start from 1

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All;

I consider the first record in the database as the record zero so the recNo
for this record is 0.

so if you want to read the first record you use : read(0);
and i see another persons use 1 for first record,

also i want to show the record Id in the JTable in client, does it is correct to use the zero as first record or record id ?

Best Regards.
Mohamed Darim, SCJP, SCJD in progress ... ( upload 1/april/2008)
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is up to you. Just document it. I use 1 because I think it is more intuitive to the user.
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anne Crace:
I think it is up to you. Just document it. I use 1 because I think it is more intuitive to the user.



And I would say "0" is more intuitive for the user (him being a programmer).
So it's really up to you

You're the boss for this assignment!

Regards,
Alex
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I started recNo with 1 but its really up to you
 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all;

thank you for your response. i will leave it 0.

Best Regards.
Mohamed Darim.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just on this, have people passed with using both 0 and 1 as the starting number for recNo ?? As i'm wondering myself.
I would have thought this would be an important point, and not open to your own decision, as surely the automated testing program of your Data class would do a read(recNo) and match up against your submitted database. If your interpretation is wrong they would not match ...
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,

First of all: welcome to the JavaRanch!

I think it's not an issue and completely up to you. I used 0 and didn't document that decision, because I never considered the use of 1 as a starting point, because everything in the Java world is 0-based: arrays, lists, stringbuilders,... And I agree with Alex: for the real user it makes no difference if it's 0 or 1 (as long as he/she sees the correct record) and another java developer could also be the user (having to make changes to your program), so it won't be that intuitive for him/her.

But if you give some good reasons to start with 1 in your choices.txt, I don't think it is a problem and you certainly won't fail automatically because of that.

Kind regards,
Roel
 
Dennis Leong
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
It sounds to me like either will pass sun's automated software test. If it does a read(0), it either works correctly and matches up the record, or throws a RecordNotFoundException, if so, checks read(1) and matches the record so either option is acceptable.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the choice is up to you ... my answer is just like everyone else

But if you look from the JTable (which start from row 0) then technicaly you don't need to do all the conversion from data to model and vice versa. From the collection (eg list, map, set) again the first item is 0. Just a point to ponder.
 
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mohamed and all ranchers

RecNo reflects primary key number..and in my view it's not god ideia start with 0. Did anyone see any database start primary key with 0 ? I not !!!. Anyway, you can identify a registry with 0.....so you can use it....is up to you. I chose start with 1 that is meaningly correct.
See you around...
reply
    Bookmark Topic Watch Topic
  • New Topic