Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: findByCriteria for types of work

 
Hugh Johns
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the above implementation I am not using regular expressions, it appears to me string methods might do, trying to keep the code as simple as
possible.
I am using startsWith() to test for database fields starting with a criteria string. Case sensitivity is not outlined in the spec, should this be
implemented?
Main question concerns the types of work field, as this field can contain a number of strings to test for (eg "Air Conditioning, Drywall, Heating")
problems are...
Can the user search for multiple types of work ?, and if so how to guess the format the search string is inputted, spaces/commas etc can vary,
therefore this can make it difficult to break the string into individual tokens (to search for).
I have tried using the String method indexOf() to test if the criteria string is in the database field. (-1 if no match), but does this still have to match
the start of a string (ie Fred matches Freddy ).
indexOf() of would look for the search string anywhere in the datafield, therefore would match "badFred", not suitable.
Is regular expressions the better path?
Hugh
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hugh
Case sensitivity is not outlined in the spec, should this be implemented?

That could be one of your design decisions which you should document
In Fly By Night Services, we had slightly different requirements, and due to my reading of them, I felt that case sensitivity was important.
Note that if you offer the user a pull down list (JComboBox) containing the possible choices, then they won't have to manually enter any data, and therefore the case will never be wrong
Can the user search for multiple types of work ?

Do you even need to allow them to search on types of work? Check your instructions, I think you only need to allow searches on is the "name" and "location" fields.
I have tried using the String method indexOf() to test if the criteria string is in the database field. (-1 if no match), but does this still have to match
the start of a string (ie Fred matches Freddy ).
indexOf() of would look for the search string anywhere in the datafield, therefore would match "badFred", not suitable.

Have you considered the String.startsWith() method?
Is regular expressions the better path?

I think you should take a good look at regular expressions. This assignment gives you a good chance to learn just how powerful they are, without the pressure of deadlines on your deliverables.
But then, after you have looked at regular expressions, you will have to decide for yourself whether you wish to use them in the assignment or not.
Regards, Andrew
 
Hugh Johns
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew
Thanks for that,
Hugh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic