• 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

Exact match and starts with

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why should the client search for exact match and the DBMain interface find method search for records that starts with the values?

Client requrement:
"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."

DBMain requirement (find method):
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".)

This seems really strange because then you have to implement two different search functions? One in Data class and one somewhere else. I have solved this but i wanted to hear what you have to say about this anyway.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Vess:
Why should the client search for exact match and the DBMain interface find method search for records that starts with the values?

Client requrement:
"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."

DBMain requirement (find method):
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".)

This seems really strange because then you have to implement two different search functions? One in Data class and one somewhere else. I have solved this but i wanted to hear what you have to say about this anyway.



Actually you only need the one that does the "starts with" since the spec also says that the fields are zero delimited. If you want an exact match all you need to do is append a zero to the end of the search string. This only works if you also trim the fields read from the data base and append a zero to them before the compare.
 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Vess:
Why should the client search for exact match and the DBMain interface find method search for records that starts with the values?

Client requrement:
"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."

DBMain requirement (find method):
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".)

This seems really strange because then you have to implement two different search functions? One in Data class and one somewhere else. I have solved this but i wanted to hear what you have to say about this anyway.



Your Data class' find method must search on partial match, and your business logic must convert those searches into exact-match outcomes.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic