File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing 'AND' and 'OR' logic in Find method.

 
Jason Moors
Ranch Hand
Posts: 188
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I�ve read a number of posts regarding the find mechanism and have ended up making myself more uncertain than before.

I�ve tried to make my database layer as generic as possible, therefore I written my find method to support searching of criteria against all fields, and limit the search to name/location within the GUI layer.

The doubt that I�ve got ringing in the back of my head is do we need to support logical �AND� and �OR� conditions. I�ve currently only implemented the �AND� condition, so any records must match criteria for all fields that are not null.

My reason for this is that I can not see a sensible (or simple) way of implementing the �OR� condition with the current find method signature, and from an application point of view it doesn�t make sense to me to support a search where you could allow the user to select a name of a hotel OR and location.

However one of my must requirements is :

Must allow the user to search data for all records, or for records where the name and/or location.

To me this requirement just means that the user can select :

  • Just the name
  • Just the location
  • Both name and location


  • Is this how you have interpreted the requirement? I�m trying to keep everything as simple as possible, and feel that the find method signature does enable the support of a complex search that you may find in a SQL database.

    Thanks

    Jason
    [ March 13, 2006: Message edited by: Jason Moors ]
     
    Xiao Di
    Ranch Hand
    Posts: 31
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Jason Moors:

    To me this requirement just means that the user can select :

  • Just the name
  • Just the location
  • Both name and location



  • That is it, do not overthink it.
     
    Jason Moors
    Ranch Hand
    Posts: 188
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the clarification!

    I'm really enjoying this assignment, and I'm doing my best to keep it simple! However sometimes I think Sun are playing mind games with the requirements, as one minute I think I clearly understand everything and the next minute I start second guessing myself!

    Jason.
     
    Mike Tilling
    Ranch Hand
    Posts: 86
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi

    It was mentionned in my assignement that

    "It Must allow the user to search data for all records, or for records where the name and/or location..."

    I understand that the user can select :

    Just the name
    Just the location
    Both name and location

    is there anyone who passed the exam and implemented the search method as I understand it

    Best Regards
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 11833
    181
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Mike,

    Many people have passed with that assumption.

    Regards, Andrew
     
    Jeroen T Wenting
    Ranch Hand
    Posts: 1847
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Just think of the implications otherwise.
    It would mean you would enter for example "name: Teddy, Location: Xanadu" and get all records where either the person is called Teddy OR the person is located in Xanadu.
    That's just not logical, you want persons called Teddy who live in Xanadu.
     
    Consider Paul's rocket mass heater.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic