Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NX: Search criteria.

Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing URLyBird and in the project requirement, it 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.

and in the comments of find method in the given interface, it
is written:

// 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)
throws RecordNotFoundException;

First one says "exactly match" whereas the other one says "matches
any field value that begins with criteria[n]". Is the first requirement
based on the find method? Or do only the values of the "name" and
"location" have to match exactly?
Can anybody please clarify this?
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim.
Best would probably be to implement the find method exactly as the provided interface's comments specify. Then add another filter or method that refines the matches returned by the find method to return only exact matches to the GUI.
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your 1st quote describes a requirement for your user interface code.
Your 2nd quote describes a method that needs to be implemented in your persistence code.
They are separate and distinct requirements that need to be individually addressed.
The code that is used to meet the needs of the 1st requirement may call upon, either directly or indirectly, the code that meets the needs of the 2nd requirement.
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course another view on this question could focus on the use of the word "allow".
You could suggest that If I did a search for the location "Smallville" (or something!) then if I got results that had
"SmallvilleTown","SmallvilleCity" and "Smallville" then I have allowed the user to perform an exact search as in the results he/she has an exact match. but then what if they type in "Small" and get the same result. this couldn't be interpretted as an exact match, but it would "allow" the user to find an exact match.
I keep it simple and implement the interface defined version (as that is clear), while the other criteria is more vague (i.e the phrase used is a bit vague - it doesn't say the returned search must only contain exact matches!)
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic