• Post Reply Bookmark Topic Watch Topic
  • New Topic

Experts opinion on Flight Seats Booking and updating about my Java Code  RSS feed

 
John Bates
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I am trying to write a code to book flight seats in my web service. basically i have created an web operation as Flight reservation and parameter input is "Flight_Name" and Seats, so i have an XML based flight details which includes few flight trip details. what i want to do here is that once the "Flight Name" and number of "Seats" is entered in the web, it should take the seats entered details and it should update this availability of seats in to my XML file

example one of the flight trip details is like ( Flight Name - AirTokiyo and seats available is 30 ) and in the web service if i write in the flight parameter as AirTokio and "seats as (reservation ) 2" then it should able to update the entry like 30 - 2 seats and should update seats as 28 in the XML file.

my Code for this is below, I would appreciate it highly if you can help me

 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgive me if I am being a little thick...but I don't see an actual question here. I see you saying "I want code that can do X, Y and Z", and I see about five times the amount of code that I, personally, would be willing to go through...but I don't see a question anywhere.
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh boy,

There are so many things going on here ...

Here's a few.

1. Initialize your logger early in the Class, that way you can reuse to help debugging.


2. Avoid method and variable names with "_". This can really screw up reflection. Use regular camel case.


3. Why use a float for an Integer operation? Can someone order a floating point number of seats?

4. Like logging, why do this more than once??


Clean these up and repost.

No offence, but I hope this is an exercise and not a real flight-booking application!

WP
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William P O'Sullivan wrote:
2. Avoid method and variable names with "_". This can really screw up reflection. Use regular camel case.

any example please...
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William P O'Sullivan wrote:There are so many things going on here ...

William, I broke up those very long lines in your post. Try to avoid them inside code blocks; they tend to produce overly wide windows for some reason (even with the horizontal scroll bar).

Winston
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote: . . . William, I broke up those very long lines in your post. . . .
That’s another bête noir of mine. It is dreadfully difficult to read code if you have to scroll left and right. Except for the beginning of the first line, the code tags preserve whitespace and line lengths, which the ordinary text loses. That is in order to preserve code indentation.
Look here for suggestions about line lengths, but most modern screens will handle 120 characters.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Bates wrote: . . . my Code for this is below, I would appreciate it highly if you can help me
Where? You haven’t deleted it have you? That would make the replies look like nonsense.
 
John Bates
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you WP yes its a exercise on flight booking, I really messed up with the earlier code and your suggestions helped me to re code it properly.. I did it another way please have a look at it..

and Hey fred you are right i did not properly mentioned it.

Campbell Ritchie I have written different code,



Thanks for your time..
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37496
540
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Bates wrote:Thank you WP yes its a exercise on flight booking, I really messed up with the earlier code and your suggestions helped me to re code it properly.. I did it another way please have a look at it..

and Hey fred you are right i did not properly mentioned it.

Campbell Ritchie I have written different code,



Thanks for your time..

1) You have a null pointer waiting to happen. What happens if the first try/catch throws an exception. flts is null, but then the next block refers to it.
2) I'd use the Java 5 style for loop since you don't use the index anywhere
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Bates wrote:Thank you WP yes its a exercise on flight booking, I really messed up with the earlier code and your suggestions helped me to re code it properly.. I did it another way please have a look at it...

You plainly missed my earlier post (and Campbell's reply).

Very long lines inside code blocks screw up the windowing, and make it difficult to read your code. Could you please correct?

Thanks.

Winston
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37496
540
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:Very long lines inside code blocks screw up the windowing, and make it difficult to read your code. Could you please correct?

Campbell meant edit it to add line breaks, not edit it to remove the code entirely.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!