• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: Logic for findByCriteria

 
Mickey Mulligan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to implement the findByCriteria method on my B&S assignment but I'm having trouble determining how the logic is supposed to work. My instructions say:



So, given that there are 6 fields in my project, should I provide a six-field search form in the GUI, and do an AND search with the data inputted? eg.



Of course I could do an OR search that way too.

Or can I get away with doing one search box for the GUI (like Denny's DVD's) and performing an OR search on each record for that value? eg.



Is it ok to go with the latter, easier method, or would this be frowned upon by Sun?

One other thing - I'd like to throw an exception or return 'null' if a parameter in the wrong format is passed (eg. the 'criteria' array has a length greater than the no. of fields). Is that considered good form?
[ March 18, 2006: Message edited by: Mickey Mulligan ]
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I debated the 'AND' and 'OR' logic, but came to the conclusion that the method signature didn't provide the ability to specify the two different conditions. i.e all you can pass is the criteria strings for each field to match.

http://www.coderanch.com/t/188067/java-developer-SCJD/certification/Implementing-OR-logic-Find-method

If there are no matches found or if the wrong number of fields are provided I just return an empty array (which I think is better than returning null).

Jason.
[ March 19, 2006: Message edited by: Jason Moors ]
 
Mickey Mulligan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jason, your advice has proven most useful! I plan to implement something similar to what you described for my assignment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic