aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes must recNo start from 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "must recNo start from 1" Watch "must recNo start from 1" New topic
Author

must recNo start from 1

mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
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

Joined: Aug 29, 2005
Posts: 223
I think it is up to you. Just document it. I use 1 because I think it is more intuitive to the user.


SCJP, SCJD
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
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

Joined: Sep 13, 2007
Posts: 82
I started recNo with 1 but its really up to you


SCJP 5, SCWCD 1.4, SCJD 5
mohamed sulibi
Ranch Hand

Joined: Sep 04, 2005
Posts: 169
hi all;

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

Best Regards.
Mohamed Darim.
Dennis Leong
Greenhorn

Joined: Jul 08, 2009
Posts: 9
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 ...


cheers,
D
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4919
    
  10

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


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Dennis Leong
Greenhorn

Joined: Jul 08, 2009
Posts: 9
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

Joined: Sep 13, 2007
Posts: 1966
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 484
    
    2

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...


Fernando Franzini - Java Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: must recNo start from 1
 
Similar Threads
B&S 2.3.2 record number
B&S: Quesion about RecNo
NX:DataInputStream Java IO
NX: URLyBird Database Record Number Question
URLyBird what do you use as recNo