• 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

NX: Search Condition - AND/OR

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Developers,
I have a question regarding search condition: AND / OR for URLy 1.2.2 project.
In the Instructions it is stated:
"UI 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."
and:
"public long[] findByCriteria(String[] criteria);
A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]."
From the two statements above, does it mean that when user selects criteria (other than ANY) for Name and criteria (other than ANY) for Location user still can choose either AND or OR from say ComboBox to specify logical combination?
For example:
---- ThisName OR ThatLocation
or:
---- ThisName AND ThisLocation
If yes then criteria for Name and Location together with the logical search condition must be communicated to the Data module.
Or does this simply mean that if criteria for Name is not ANY and criteria for Location is not ANY then AND is automatically assumed and it satisfies this requirement: "... 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."
Could you please explain this requirement.
Thank you in advance!
+Seid
[ December 06, 2003: Message edited by: Seid Myadiyev ]
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seid,
This recent discussion and its link(s) should help you.
Best,
Phil.
[ December 06, 2003: Message edited by: Philippe Maquet ]
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Philippe,
Thank you very much for your reply. I have read that thread and even participated in the discussion, however I still have this question.
I am not clear on whether or not for my assignment requires me to have AND/OR choices for user when both criteria for Name and criteria for Location are selected.
Thank you again!
+Seid
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seid,
Simply *AND*. I cannot tell you more...
Best,
Phil.
 
Seid Myadiyev
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe,
So what you said is this:
-----
It simply means that if criteria for Name is not ANY and criteria for Location is not ANY then AND (not OR) is automatically assumed and it satisfies this requirement:
"... 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."
-----
Did I understand you correctly?
Also does it apply to all vesrions of SCJD projects?
Other developers, please also share your view!
Thanks!
+Seid
[ December 06, 2003: Message edited by: Seid Myadiyev ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seid,

Did I understand you correctly?


Yes !
"... 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."
The "and/or" must be understood as :
The user is allowed to search on Name OR Location OR (Name AND Location).
The OR applies to the criteria used, not their values, which wouldn't make sense anyway. In a previous thread I wrote :
"Do you think a customer could ask for a room in New York OR in a Hilton hotel ?". Obviously, the answer is no. Now if you try "OR" with any other criteria combination you get similar dumb requests :
Imagine a customer asking to sleep :
  • in San Francisco OR in a smoking room
  • in a Hilton OR on December 15
  • ...


  • Would be stupid, right ?

    Also does it apply to all vesrions of SCJD projects?


    AFAIK. I've never seen a thread on this subject which didn't finish with another conclusion.
    Possibly Andrew and/or Jim will confirm and reassure you.
    Best,
    Phil.
    [ December 07, 2003: Message edited by: Philippe Maquet ]
     
    Seid Myadiyev
    Ranch Hand
    Posts: 196
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hello Philippe,
    Thank you very much for your last reply! It is the answer I was looking for this question!
    Thank you very much for your help once again!
    +Seid
     
    Ranch Hand
    Posts: 286
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Philippe Maquet:
    Hi Seid,
    "Do you think a customer could ask for a room in New York OR in a Hilton hotel ?". Obviously, the answer is no. Now if you try "OR" with any other criteria combination you get similar dumb requests :
    Imagine a customer asking to sleep :
    in San Francisco OR in a smoking room
    in a Hilton OR on December 15
    ...
    Would be stupid, right ?
    Best,
    Phil.
    [ December 07, 2003: Message edited by: Philippe Maquet ]


    Hi Phil,
    Very funny use of OR.
    [I'm certain I've seen a face rolling and laughing, but I don't see it under "Instant Graemlins."]
    There is little doubt that Sun's use of the phrase
    "items where the xField and/or yField fields"
    means items where the
    1. xField, or the
    2. yField, or
    3. Both
    However, it's common incorrect usage for some software developers to mean
    and/or as
    means items where the
    1. xfield, or the
    2. yField, or
    3. both, or
    4. xfield or yField
    Granted, Sun most likely does not mean this, and so it is highly unlikely
    anyone would receive a jot of demerit for not implementing case 4.
    However, I was thinking could here possibly be any use for the OR
    as an option to the user? Certainly, some of your examples are hillarious,
    but what about when OR is applied between a hotel name and a location thus:
    Jim and Samantha Jones are about to go on a spur-of-the-notice, short
    vacation. Samantha is so enamored with "Smith's B&B Inc." that she has
    warmingly suggested that any Smith's B&B anywhere in the world would
    be a great place to vacation. Jim, on the other hand, desires to take a
    vacation in Oz County (and he doesn't care about which hotel he stays
    at).
    Instead of Jim making two different searches, one on Oz County, and one
    on Smith's B&B Inc. anywhere in the world, he makes one search:
    "Smith's B&B Inc." OR "Oz County".
    Is the above search plausable? Or outright rediculous? Obviously I don't
    want to consider putting in the OR option if the grader will make be blush
    In short, if each search is plausable, then OR'ing the two searches together
    to get the output on one page is plausable?
    Again, I'm not implying that anyone will lose points for using OR; but, I'm
    checking that using OR is not too far out.
    Thanks,
    Javini Javono
    [ January 20, 2004: Message edited by: Javini Javono ]
     
    Ranch Hand
    Posts: 160
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,
    I believe the and / or is not boolean operators in the context of the specification. How do you describe this in everyday English to someone who are not trained in Boolean Algebra.
    Search by hotel,
    Search by city,
    Search by hotel and city,
    In short, search by hote and / or city !!!
     
    Ranch Hand
    Posts: 619
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I agree with Frankie and Phillipe (his hilarious example had me laughing out loud), in the context of the assignment, name and/or location can be taken to mean either: name, location, or name and location.
    Even if you still believe that a user might want to book a particular name OR a particular location, it's possible to accomplish that by simply making two queries. The first returns all the records that match the name, which the user can view and select one if desired. The second returns all the records that match the location, which the user can view and select one if desired.
    In this case you can make a very reasonable assumption and have a fairly easy time implementing it, or you can make a technically possible though rather implausible assumption and have a fairly miserable time implementing it. Simplicity should always be preferred to complexity when in choosing simplicty nothing of importance is actually being sacrificed.
    Hope this helps,
    George
     
    Philippe Maquet
    Bartender
    Posts: 1872
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Javini,
    I agree with Frankie and George (which is quite normal after all, as they both agree with me).
    OK, let's say that your Jim and Samantha's example makes some sense. The problem comes from :
  • that your example is an extreme one, meaning that it consists in some *very exceptional* usefulness of the "OR" support;
  • if you implement that "OR" support at the GUI level, you'll have to build some more complex GUI, a too much complex one for the 99.999% out of the cases your users will have to deal with every day;
  • and if you do it, the provided findByCriteria() server-side interface simply cannot be used to serve your queries.


  • Now what I *really* think of your example, is that Jim and Samantha should definitely separate.
    Best,
    Phil.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic