• 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

Booking actions

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the booking went through OK i just repeat the previous search to refresh the information.
 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot Ben!
Sam
 
Adam Till
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that Adam
Sam
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
reply
    Bookmark Topic Watch Topic
  • New Topic