This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which collection should i use in following situation?

 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Junilu Lacar
Bartender
Pie
Posts: 7766
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Azrael Noor
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 7766
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@junilu has the right answer. User real names for the xml tags, eschew the obfuscation.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic