| Author |
Which collection should i use in following situation?
|
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
I have list of Two Strings:
1) Value Name
2) Column Name
In web service response if i will get Value as EXDN.
Then we need to store EXDN in Column name - E_X_D_N of Table
and if i get value FLTP
Then we need to store FLTP in Column name - F_L_T_P of same Table
I want to put these string in collection, where i can check
myCollection.exist(webserviceresponse)
and i get location of existence in collection
and fetch column name from that location from collection.
I need to make dynamic query
|
Regards
Azrael Noor
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
|
|
I see you have an "architect" with a warped mind who likes to make things much harder than they need to be. My solution for this type of situation has always been to refactor and make things simpler and straightforward. The problem here is trying to put too much flexibility, something that good designers should consider as "technical debt." Good luck.
Edit: Sorry, I tend to take some my real-world frustrations out on imaginary characters such as the "architect with a warped mind"; ignore my mini-rant there -- the decision to put more flexibility than is really necessary is still technical debt though and you should consider simplifying the design so you don't have to go through so many gyrations and machinations in code.
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
Azrael Noor
Ranch Hand
Joined: Jul 29, 2010
Posts: 369
|
|
Mr Lacar, You mean i should only use String object, with fors and ifs?
In xml we have data like
EXDN|E_X_D_N Column ; SSDN|S_S_D_N column
then by splitting it from semicolon(;), the other data is is put into MAP with key and value i.e EXDN as key and E_X_D_N Column is value.
And when in response we check code we find value key i.e XSDN exist,
then put the column name into String buffer.
then use string buffer to create dynamic query
and with your Reply i think you are saying me to use Simple objects rather then move in to collection. Am i correct?
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
|
|
No, I'm saying your XML is too convoluted and not the right way to use XML. XML is meant to represent a structure, so why do you embed two logical values in one XML value (column name; value)? That doesn't make sense. If anything, you should have something like this:
or probably even better
Why make it harder by requiring consumers of the XML to parse the value of an element? That's a bad design and misuse of XML.
|
 |
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4422
|
|
@junilu has the right answer. User real names for the xml tags, eschew the obfuscation.
|
 |
 |
|
|
subject: Which collection should i use in following situation?
|
|
|