Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructing object  RSS feed

 
Swapna latha
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a query in constructing an object and storing it in database in json format.

Its in air domain industry. Need to construct an ojbect and store it in database in json format so the other applications can use the same object for various test automation scripts.

What i have done is i have created a class called PassengerDetails and inserted to station, from station etc., as below.


The passenger type also changes, like infants, companions etc., and i am not understanding how to handle it in class PassengerDetails. I have a guess like i have to add another class for PassengerType. Please correct me if i am wrong and suggest me how to add that passengertype details.

And I have created one ticket class (one ticket for each passenger, if 3 adults are there then 3 tickets and and three tickets are associated with one unique PNR). Here we have to store how the ticket is purchased, i mean by cash or credit card




We are having different payment types like Creditcard, cash, vouchers, refund amount etc., I am in confusion again how to handle this in the above PaymentDetails Class and how to link this class with TicketInformation and PassengerDetails




For multiple tickets, we have one PNR.



Now i have a query like, if there is modification in flights or dates etc., new ticket will be issued. Now the question is how to store this new tickets and old tickets so that the user who retrieves the list of tickets can understand that there is a modification and hence there are new tickets and old tickets.

The other scenario is that if there is an addition of additonal passenger then not only the ticket changes but also the PNR changes, Now the question is i want to store both new and old PNRs and associated tickets.

For multiple PNR's how to write the class, do i have to write a class where it has List<PNRDetails> as instance variable. I messed up the code and i am in confusion. Could any one suggest better approach in modifications of code.


Thanks & Regards,

Swapna.




 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just from design point of view, it would be better if you just write down all the business requirements in a paper and just take your time to visualize how it should work as per your understanding.

Json is just a data format, it will not be a blocker for your application. From what I remember from my previous projects, you can have objects of objects also. Analogy would be use of composition I guess.

Storing and retrieval would be frequent in your case, hence you should design it in such a way that there or no unnecessary data conversions from application to db and db to application.

I am no db expert, but in layman way if I have a column in my db that either links to any previous ticket/ record or a column that tells that this row is updated, that should prove to be quite useful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!