wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Booking actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Booking actions" Watch "Booking actions" New topic
Author

Booking actions

Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
In my bookFlights() method, in addition to simply subtracting the number of seats booked and writing the new total available to the database, I was thinking of also then either:
1)Subtracting the number booked from the total stored in the model itself and then firinga model change event to the Gui.
Disadvantage is:- that other clients may have altered the num of seats in between the time the user did the flight search and the time they booked their seats such that subtracting the number from the model's count may still give an incorrect value for the num available.

2)Once the booking is complete return the total seat available as stated in the database and set the model to that number then fire a change event to the gui.
Disadvantage:- that is another client has changed the num of seats available in between the search for flights and the booking then the user may see the value in the JTable decremented by more than the number of seats they booked to account for other clients bookings as well.
The requirements state

It is not necessary to provide for live updates on multiple clients when new bookings are made at other clients.

But this IMO does mean that the gui should not reflect bookings made at this client.
How have others handles this if at all?
Thanks as always Sam
Adam Till
Ranch Hand

Joined: Oct 11, 2002
Posts: 41
Sam
When I booked a flight, I locked the record, checked it had enough seats, if it did reduced the number by the specified amount, returned a success message and called a refresh method that refreshed the GUI.
This means that when the flight is booked it takes into account the GUI might be out of date due to another client booking for example all the remining seats. It also refreshes the GUI to show most recent snapshot.
Hope that helps,


Adam Till<br />SCJP SCJD SCWCD
Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
So adam you are effectively doing a fresh search after each booking to get all the latest data for the original search criteria?
If so do you find it greatly effects performance?
Ta Sam
Kevin Cao
Ranch Hand

Joined: Jun 19, 2002
Posts: 55
Sam,
How about not showing available seats. If the client book more than available seats, inform him not enough seats available. So you do everything behind the scene. Just my thought.
-Kevin
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

How about not showing available seats.

Do you mean, hide this field in the JTable? That's a guaranteed fail.
Eugene.
Kevin Cao
Ranch Hand

Joined: Jun 19, 2002
Posts: 55
Eugene,
Why this is a guaranteed fail. I don't see any requirements that I must show this field. The other thing we can do is to check the value of Availabe Seats, show "Seats Available" in that field if >0 , otherwise "No Seats Available" . The bottom line is before the user click "bookFlight" button, the available seats field is never correct(in theory).
Kevin.
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937

Why this is a guaranteed fail. I don't see any requirements that I must show this field.

It is implicit in the requirements that you must use common sense.
If you don't see in the requirements that you must show Price, Day, Time, and Duration fields, it doesn't mean that you could blindly ignore them and hide them from the user. It's not in the requirements that you should spell the labels on the GUI correctly, does it mean you would not make an effort to do so?
Eugene.
Kevin Cao
Ranch Hand

Joined: Jun 19, 2002
Posts: 55
Eugene,
Thanks for your response. Talk about common sense, if you book an airline ticket in real world, how many will show you available seats? So far NONE for me. Every client only gets a snapshot of the database. Time, Price, Duration..., those are static fields, Seats is dynamic and it is supposed to change all the time. And there is no way you can keep track of it on the client side and this is not a requirement of this assignment. I think the whole thing is just matter of taste as long as you can justify it.
Kevin
Max Habibi
town drunk
( and author)
Sheriff

Joined: Jun 27, 2002
Posts: 4118
Originally posted by Eugene Kononov:

It is implicit in the requirements that you must use common sense.
If you don't see in the requirements that you must show Price, Day, Time, and Duration fields, it doesn't mean that you could blindly ignore them and hide them from the user. It's not in the requirements that you should spell the labels on the GUI correctly, does it mean you would not make an effort to do so?
Eugene.

I think Eugene is exaggerating to make point, but it i a valid point. From the grader's point of view, they want your system to be easy to understand, and similar to what they're used to seeing. Now, they are probably used to seeing the number of seats available.
OTOH, your design choice is defensible, if you argue that you don't want to give the user 'too much' information, and thus potentially reduce the complexity of the UI.
While I can't speak for Sun, I doubt that it's a 'automatic' fail. That being said, it's probably not the most conventional approach.

All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4


Java Regular Expressions
Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
So how did you other guys handle it then? - did you do a refresh of all the information after a booking like Adam or just subtract from the currently displayed total even if this may not be a true representation of the actual number of seats remaining?
Many thanks Sam
Ben Ritchie
Ranch Hand

Joined: Nov 18, 2002
Posts: 98
If the booking went through OK i just repeat the previous search to refresh the information.


SCJP1.4, SCJD, SCEA (in progress)
Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
Thanks alot Ben!
Sam
Adam Till
Ranch Hand

Joined: Oct 11, 2002
Posts: 41
Sam
Performance doesnt suffer at all. Im sure there is a small time lag. But unless you can do something constructive or less boring than sit around for several nano seconds its not an issue.
You need a snapshot of all the data in the JTable to start with. You then need another to check that the seats are still available during the booking process. Then another to show that the seats have been removed for your flight (dont just remove it from the JTable).
I did work for a very brief time in a travel agents (Sun cant fail me now!!!) and they do show seats available.
Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
Thanks for that Adam
Sam
Eric Blische
Greenhorn

Joined: Feb 02, 2003
Posts: 16
Performance doesnt suffer at all. Im sure there is a small time lag. But unless you can do something constructive or less boring than sit around for several nano seconds its not an issue.

Thanks for that Adam, after a long day that made me smile !
Eric
 
Don't get me started about those stupid light bulbs.
 
subject: Booking actions