• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to design java class to hold data  RSS feed

 
jacob deiter
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scenario please which is best solution for this

1) I have web application ,in Which many user place a order for a product.Here I have to simeple java class which will save all data

2) I have to get the report which display immediately

Note: Data should be maintained in memory.so Do not bother about Database connection

Please suggest how design single class ,which collection should be used??
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:I have web application ,in Which many user place a order for a product.Here I have to simeple java class which will save all data


to where the class save the datas? itself? I guess you want to use TO(transfer Object) class .
 
jacob deiter
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class should select a java data struture.I wnat to know which data struture ?? and details of implemetation ??
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jacob deiter wrote:class should select a java data structure.I wnat to know which data structure ?? and details of implemetation ??
You decide what sort of data you are saving, then that will determine the data structure you require.
 
jacob deiter
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You decide what sort of data you are saving



can you explain this little more detail
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you explain this little more detail


I am guessing you want to save order information. Like product name, price, date ordered? You need to know what type of information you want saved before you can implement a solution.
 
jacob deiter
Ranch Hand
Posts: 588
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am guessing you want to save order information. Like product name, price, date ordered?



Yes You are correct.Now please suggest a solution best suited for this
 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to create a java bean with all the fields you require [like product name, price, ID etc], and as and when the user purchases one, you will have to populate this bean with the right data. For this you cannot use any standard data structure, as only you know what your application requires.

However, there should be some way to persist this data so that you can use this for a report generation. From your question, I understand that you are not using a database... so where else ? Does "in memory" mean, you are planning to use the session object to hold this data ? If yes, then it is a bad idea, but if you insist, then you can add an implementation of List object [arraylist, linkedlist etc] to the session, and as and when a product object is created, you can add it as a node to this list.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!