• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

And/or search logic

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I would like to discuss and/or logic for search. My instructions say that gui should allow user to search "for records where the name and/or location fields exactly match values specified by the user".

It doesn't seem so clear to me now. The statement consist of two in real:
...where the name and location fields exactly match values...
...where the name or location fields exactly match values...

I'm not sure if the second should be programmed as "or" match. Or in gui as "xor" - user can select name xor ( ) location. Its common end user logic.

If it would be real or logic it could be difficult to user to understand - and there would be no clear way how to search (for example) for name only.

Thanks for your opinions.
P.
[ October 15, 2006: Message edited by: Petr Hejl ]
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from the previous discussions ,
i have concluded the following

if only name is entered -- search for name records
if only location is entered -- search for location records
if name and location is entered -- search for the record that matches naem & location both.
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In such case you can't (theoretically) search for name "", can you?
 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the gui if you don't specify any criteria ( lets say name & location are empty -- blank in the gui ) you return all records..
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any other opinions please?

Should I implement true or logic or is this enough?

1) name and location not empty (and)
2) name not empty, location empty (or - search for name)
3) name empty, location not empty (or - search for location)
4) name and location empty (search all)

Do you implement selection through combo boxes (this has issues if we consider data can change)?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Petr Hejl:

1) name and location not empty (and)
2) name not empty, location empty (or - search for name)
3) name empty, location not empty (or - search for location)
4) name and location empty (search all)

[/QB]



This is the way I have implemented it (I have the exact same requirement). Don't know if it is valid though, I have not submitted yet.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to add a case:
5) Name not empty and Location not empty ( search by OR)
Any record having specified Name or Location should be returned by the search.
 
Bhavik Patel
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont see any logical for case 5..

if you got amazon.com and enter author ="XYZ" and TITLE="ABC" .. Do you expect to get results for any books from XYZ author... You are specifically aksing
for contractor working at this location whose name is this.. I believe this case should be only AND. If you see the previous posts , theres a huge discussion on this topic.
 
Joe Zhou
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure how your 'Instruction.html' states the user interface.
Check the following requirement:

It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

For no matter what values for name/location, the logic should include 'and/or'
 
Petr Hejl
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is exactly what I'm asking for To implement _real_ or or not to implement it?
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My instructions.html file clearly says:


It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user



I think the search mechanism that we implement must allow the user to search by:

1. just name
2. just location
3. name and location
4. name or location

Since the findByCriteria() proposed by Sun in the assignment searches all records that look like the provided criteria we'll have to provide empty Strings values for all the values in the findByCriteria() method, except for those fileds we are looking for.

Once we have the result set, we remove all the values not matching the business criteria.
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I add a flag (UI == checkbox) so that the user can select whether he wants to use AND search or an OR search in that way it is on him to select rather than we presuming things based on empty values for the various fields.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic