• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

the search method

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm not sure if I have implemented the search functionality correctly in my application (B&S).

The requirement 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."

I have in my application the name and location fields and the search button.

1) When the search button is pressed and the name and location fields are empty then the application retrieves all the records for the user
2) When there is value only for the name field the application retrieves only the records where the name field matches
3) When there is value only for the location field the application retrieves only the records where the location field matches
4) If there are values for the name and location fields then both fields in the database has to match

What you think "exactly match" means? Is it ok to match from the beginning and also use the method String.equalsIgnoreCase?

BR,

Mika
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Mika!

One question about your approach... in the 4th case, you have the search for name and location. When do you have the search for name or location, and both name and location are filled?

And by exactly, I assumed that it means the whole word, no matter the case. So, if the user tries to find a record where location = Sao Paulo, and there is a record in the database that has location = SAO PAULO, then this record will be retrieved, if the user chose name or location, for instance.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mika,

I had the same implementation as you: 4 possible search scenario's exactly described like you did in your initial post.

My interpretation of "exactly" was "exactly" (case-sensitive), so "Sao Paulo" is "Sao Paulo", not "SAO PAULO" or "sao paulo", but "Sao Paulo".

Kind regards,
Roel
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know, one thing that occurred to me now is that maybe this could be a good place for the Policy pattern; you can have an interface called SearchPolicy, then you can have implementations for the search, like CaseSensitiveSearch... this way, it should be easier to change the way the search mechanism works, since some people choose to implement a case-sensitive search, and others choose to implement a case-insensitive search.
 
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
  • Quote
  • Report post to moderator
Almost forgot to say: the find method in my Data class is a case-insensitive search
 
Mika Tapanainen
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

and thanks for the answers.

Roberto Perillo wrote:
One question about your approach... in the 4th case, you have the search for name and location. When do you have the search for name or location, and both name and location are filled?



Roberto, if I have values for both name and location, currently I don't have "or search" for both values. I think (and hope) cases 2 and 3 above fullfill the "or search".
 
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
  • Quote
  • Report post to moderator
Mika,

Like I already pointed out in my first post: a search on "name or location" is not required.

Kind regards,
Roel
 
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic