GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Lock on flight no. or rec no. 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 "Lock on flight no. or rec no." Watch "Lock on flight no. or rec no." New topic
Author

Lock on flight no. or rec no.

Alex Sbityakov
Ranch Hand

Joined: Jul 23, 2001
Posts: 49
My feeling is that people seem to be locking on record number. Has anyone done it on the flight number, instead? Since, it is the PK, it will always be unique even in the unlikely case of merging databases.
I think locking on flight number is superior because you do not need to keep any map of flight no (returned by the gui) to rec. no. The idea is that you don't want to find the corresponding record no of the given flight number in the booking method.
Just curious, what do people think?
Alex
Alex Gregory
Ranch Hand

Joined: Jun 15, 2002
Posts: 46
i personally like record number because it is purely numeric, not alphanumeric. Also, it is more intuitive since datastructres like hashtables usually accept Integers for keys, not Strings. But thats my 2 pennies, i dont know the right answer.
Robin Underwood
Ranch Hand

Joined: May 01, 2002
Posts: 117
Some of Sun's Data methods acts like flight number is unique, but I think that is a flaw in their code. In real life, airlines have the same flight number on different days, so there would be duplicates. I would stick to using record number in your code, don't change Sun's code, and document the problem.
Alex Sbityakov
Ranch Hand

Joined: Jul 23, 2001
Posts: 49
Robin,
But if you look at the flight number in the file, the airline is part of the string - the first two letters.
If you decided to lock on record number, did you keep a hashtable with key: flight number and value: record number somewhere in your code?
Alex
Robin Underwood
Ranch Hand

Joined: May 01, 2002
Posts: 117
No, I didn't break apart the flight number string.
Record number should be the unique value. There's no reason to think that flight number would be unique, other than that it happens to be unique in Sun's db.db file.
In real life, airlines seem to use the flight number to identify regulary scheduled flights. The flight number isn't unique even for the same airline.
 
GeeCON Prague 2014
 
subject: Lock on flight no. or rec no.