• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find method

 
Rahim Nathwani
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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

 
Dennis Grimbergen
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
Roel De Nijs
Sheriff
Posts: 10591
140
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 19
  • Mark post as helpful
  • send pies
  • 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: 10591
140
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic