• 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

Find method

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was confused about the find/search requirment but after searching a few posts, I'm even more confused . Hope you guys can help me clarify it

The requirement in the interface is as follows:

// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. 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]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public int[] find(String[] criteria);

The requirment in the document:
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.

The way I was going to implment this was too as per Roel's post long time ago:
GUI contains 2 fields: one for location and for name. So the user has 4 possibilities:
- retrieve all hotel rooms (leave both input fields empty)
- search on a name (enter a value in the input field name and leave the input field location empty)
- search on a location (enter a value in the input field location and leave the input field name empty)
- search on both name and location (enter a value in both input fields)

The thing that is confusing me the most is that in the interface states that "value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)" but in the document search "records where the name and/or location fields exactly match values specified by the user" - These seem to say the opposite - Any thoughts to clarify this for me

Or how did others implement the search?

Thanks

 
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems weird, you're right. In the find method in the Data class you do what you have to do there. In the GUI you narrow your search results by filtering on exact matches only.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not the opposite at all. It's just a small difference in how your data class should work and what the business guys (and girls) want. Which happens in real life too.

So I implemented it as required: my Data class will return "beginning with" matches, my GUI will only show exact matches (so my business service does a bit of filtering).
 
Rahim Nathwani
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys,

Just so I am clear - There is 2 requirements

1. Business where I show the user the exact match via the GUI
2. Data class req, where I return "beginning with" matches

Thanks
Rahim
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


An example of how I handled this difference in requirements, can be found here.

 
reply
    Bookmark Topic Watch Topic
  • New Topic