This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CriteriaFind Confusion

 
Raju, Gentle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following question on CriteiaFind method. Help approciated.
1. Does CriteriaFind be Generic or should we do only
Carrier='SpeedyAir',Origin='SFO'" ? I think it should be
generic. But the question is how much generic.
Is the user allowed to enter in the criteria the field name
in any order and in any order. Also user can give some of
the filed names or all of the field names in the criteria.
If so this method becomes very ugly to find out all the field
names and corresponding values and put them in the order that
is acceptable by method find ( or modified version of find
method ). So please give me your advise here.
 
Marco Barenkamp
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The user must be able to search for every field using
an arbitrary combination.
But it is not THAT difficult. My solution took about 50 lines.
Have fun!
 
Raju, Gentle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marco Barenkamp,
Thanks for the reply. When you say arbitrary combination, does that mean any kind of query should be handled. I can write a
method that can parse the string and arrange them in some order and I can create a method like find and get the results. This will work as long as you use on "filedName=Value" in the criteria string and do not repeat the same filed two time in the query. Also user can enter these fields in all or some and in any order. I can write a method that can handle this requirement.
My Question is: Are we expected to handle
AND, OR < > and etc operators in the criteria String.
For Example:
Origin='DEN' OR Origin='SFO' AND Price > '400' AND Price < 1200.
Queries like this will be very difficult to parse and method requires a lot of intelligence.
You�re Comment please

[This message has been edited by Raju, Gentle (edited September 17, 2001).]
 
Pratibha Gayake
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think handling AND, OR, <> in the criteria String will complicate the matter, and which is not required in the assignment.
I think you should consider only "if the name/order/number of the fields is/are changed" then the method criteriaFind() should handle that without changing the implementation.
According to me this is generic implementaion of criteriaFind().
Pratibha
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have approached the criteriaFind method in the following manner:

  • Parse the criteria into field / value combinations (Utility Class)
  • Locate the position within the datasource for each field being searched. (If there is an invalid field the method returns with null).
  • Search the datasource for the actual value for the associated field.
 
Raju, Gentle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark, Pratibha, Terry
[This message has been edited by Raju, Gentle (edited September 18, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic