Results 1 to 4 of 4
- 06-13-2011, 10:34 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Creating objects with automatic names
Hi all!!
Wondering if anyone can shed a little bit of a light on something that has been puzzling me for a little while now.
I think it's best explained with a verbal example...
Let's say that I'm designing a program for a client at a GP Surgery. This program needs to have, within its UI, an area to register a new patient, taking various details (name, DOB, sex, etc), and creating two-way links with various other objects (doctors, nurses, etc).
Now, when this new patient is generated through the various inputs in the UI, how can I name the resulting new objects in a coherent manner. For example, the first patient object generated is called 'patient1', the second, 'patient2', etc.
Or is this not possible? If that's the case, is it best to add them to a map? With some form of uniquely generated ID instance variable that can then be searched for within the map?
Any advice, thoughts, comments, assistance, would be greatly appreciated. :)
- 06-13-2011, 10:52 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I don't think you can create dynamic variable names, you can however add them to an ArrayList. If this wasnt what you were asking for, please say so.
- 06-13-2011, 11:23 PM #3
You can get the effect of generated variable names by using a Map. The key would be the generated name: Patent1.
- 06-14-2011, 06:32 PM #4
Member
- Join Date
- Jun 2011
- Posts
- 2
- Rep Power
- 0
Thanks guys for your speed replies.
An ArrayList would do what I was after, but I think a map is indeed better suited.
I think having a coordinating object to hash their DoB, first and second names into a checksum, and using that as the key with the corresponding object as the value should do the trick. Then I can simply have a lookup interface that their information can be input into, the same algorithm used to create a checksum, then simply match them up.
Is that something similar to what you would do with this given situation?
Thanks again for ur replies guys. Really appreciate it. :)
Similar Threads
-
Creating a list with objects
By thine_iniquity in forum New To JavaReplies: 6Last Post: 03-25-2011, 03:55 AM -
creating dynamic objects?
By alacn in forum New To JavaReplies: 4Last Post: 06-04-2010, 03:51 AM -
creating public objects
By TaxpayersMoney in forum New To JavaReplies: 2Last Post: 05-19-2010, 06:50 PM -
Creating abjects with different names
By bugger in forum New To JavaReplies: 3Last Post: 11-26-2007, 12:14 PM -
How to get column names for Oracle.sql.Datum Objects
By harikanth in forum JDBCReplies: 0Last Post: 11-08-2007, 08:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks