In general the whole post is about boundary conditions
Firstly, I'm in little doubt if my implementation of findByCriteria is correct. According to the specification:
//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".)
What if criteria[n] = "" - that means an empty string?? Is it supposed to match anything (like a null value), or literally an empty string in the column to which the n index corresponds??
I implemented it in a way that it matches anything (just following recursively the path: if "Fred" matches both "Fred" or "Freddy", than "F" matches anything that starts with "F", so "" matches anything).
What comes next is the searching algorithm.
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
What does an empty field in the search criteria mean here, anything or literally an empty string??
If an empty field means anything, the search with the following criteria:
name = "Castle" AND location = "" will return only the records that have "Castle" in the name column, similarly name = "Castle" OR location = "" will return the whole database contents.
On the other hand, if we assume that an empty field means literally an empty field in the database, the:
name = "Castle" AND location = "" will return records that have "Castle" in the "Name" column, and "" (an empty string) in the "Location" column - in case of the provided database file the result set will be empty.
The name = "Castle" OR location = "" in that case will return only the records that have "Castle" in the name column - since in the provided database file there're no entries with an empty location field.
Which of the above is a better approach?? Guess this is a good thing to place in the choices.txt
PS. BTW, Please be sincere, and tell me if I'm getting paranoid - maybe it's not too late
[ December 01, 2005: Message edited by: Krzysiek Hycnar ]