my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: question on gui search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S: question on gui search" Watch "B&S: question on gui search" New topic
Author

B&S: question on gui search

fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
my spec 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.

does that mean if user type "Fred" in name field in gui and click on search, it must return all contractors with "Fred" not "Freddy"? and is case sensitive? currently my program is not case sensitivy and uses .startswith().

thanks in advance
Mary John
Ranch Hand

Joined: Sep 17, 2007
Posts: 109
Hi


Yes you are right. The result should be Fred alone as spec says exactly match.

My assignment has the same sentence about exact match.

I am not sure about the case sensitive, but I would assume that it should be case sensitive too. anyway lets hear what other have to say...


SCJP 5.0<br />SCJD working on it
John Mattman
Ranch Hand

Joined: Feb 18, 2008
Posts: 45
These are the instructions in my project.

User Interface instructions

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.

DDBMain Interface

/ 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".)
public int [] find(String [] criteria)
throws RecordNotFoundException;



My understanding from the above is, if i pass a string "Fred" the query should return records that has name starting with Fred or Freddy.

for example if the data has three records

First Name
---------------
Fred Campbell
Freddy Jones
Fredricks Doe

I would return the three records as they all start with Fred.

OR

Let my interface return three records. but my support method which calls the find(String[] criteria)method should filter the other two records(Freddy,Fredricks). This way both the requirements are satisfied.

which way is right?


Please correct me if i am not understanding it properly.

----------------------

John

[ April 10, 2008: Message edited by: John Mattman ]
[ April 10, 2008: Message edited by: John Mattman ]
fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
i think none of the above 3 record should be returned, because it not exact, Campbell is extra.
If user search "Fred" only and only "Fred" is returned, please correct me if i am wrong, i am confused
John Mattman
Ranch Hand

Joined: Feb 18, 2008
Posts: 45
fei,
I am sorry for confusing you. I think it should return only the exact match. I was confused by conflicting instructions being provided. I would change my code to do the exact match.

John
[ April 11, 2008: Message edited by: John Mattman ]
fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
thanks guys, i will use exact match,,,, its not user friendly.
Gilles Marceau
Ranch Hand

Joined: Feb 17, 2007
Posts: 78
Hello guys,

i think there is a misunderstanding in this thread : when you talk about
the search feature, remember there is two levels :
* the find method of the interface you have to implement.
* the search feature of the GUI relying on the first one.

So at first glance, it may seems that your assignment instructions are
inconsistent, but if you pay close attention, you'll see that the exact
match is required for the GUI, while the "startWith" match is required for
the interface. So, this is possible to implement this way (not very
efficient, because it implies a post processing, but you have to follow
Sun's orders and implement the interface).

Hope it helps,

Gilles


SCJP 1.5<br />SCJD 1.6<br />SCBCD in progress...
Johan den Boer
Greenhorn

Joined: Apr 08, 2008
Posts: 18
Hi,

I interpreted the search as follows. I used the indexOf method to match exactly the values specified by the user in the name and/or location field. So, if the name is 'Company Freddy' or 'Fred's Company' and you are searching for 'Fred' than both records will match, but 'fred' will not.

Johan


Johan<br /> <br />scjp, scjd
 
jQuery in Action, 2nd edition
 
subject: B&S: question on gui search
 
Similar Threads
Some Ambiguity
search requirement in B&S
B&S- Find method
User search B&S
is the search case sensitive?