Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

must recNo start from 1

 
mohamed sulibi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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)
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • 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.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • 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
 
rohan tiwari
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
hi all;

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

Best Regards.
Mohamed Darim.
 
Dennis Leong
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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 ...
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • 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.
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic