aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird Search Options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBird Search Options" Watch "URLyBird Search Options" New topic
Author

URLyBird Search Options

Jason Nesbitt
Greenhorn

Joined: Aug 16, 2004
Posts: 16
The requirements of the user interface state that "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."

Would it be enough to have the search return all records when no criteria is specified or does there need to be an explicit option to return all records such as having another button that says "List All"?

Also, I noticed that there are a bunch of different versions of the URLyBird assignment floating around out there. Are these given out at random or does it depend on the time that you buy the assignment? Mine is 1.1.1

Thanks

Jason
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Hi, what is "URLyBird assignment", I remember my assignment is FBN, something like air ticket ordering system.

Thanks
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Jason Nesbitt:
The requirements of the user interface state that "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."

Would it be enough to have the search return all records when no criteria is specified or does there need to be an explicit option to return all records such as having another button that says "List All"?

Also, I noticed that there are a bunch of different versions of the URLyBird assignment floating around out there. Are these given out at random or does it depend on the time that you buy the assignment? Mine is 1.1.1

Thanks

Jason


Someone else correct me if I am wrong, but I believe what it is saying, is that, if the search field is empty and the user hasn't entered a search string, all of the records should be displayed.


SCJP 1.4<br />SCJD 1.4
Sean Gildea
Ranch Hand

Joined: Jul 01, 2004
Posts: 81
Thats what I believe also. I dont think you need to list all records button. I have the URLyBird assignment as well.

However,

In the DBAccess interface, under findByCriteria, the comments for it say...
"Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value."

I'm confused, do we need to implement every record value is matching that in criteria or can we just implement it so a record value matches the name and location in the criteria?
[ November 11, 2004: Message edited by: Sean Gildea ]

SCJD, SCBCD, SCJP
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Sean Gildea:
Thats what I believe also. I dont think you need to list all records button. I have the URLyBird assignment as well.

However,

In the DBAccess interface, under findByCriteria, the comments for it say...
"Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value."

I'm confused, do we need to implement every record value is matching that in criteria or can we just implement it so a record value matches the name and location in the criteria?

[ November 11, 2004: Message edited by: Sean Gildea ]


I've started to ask this same question in the past week. Currently, my search method in my Data class is only programmed to search for a contractor name and location, nothing more. Would I fail the assignment if they felt that I didn't implement the method correctly?
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
I don't think you would fail the assignment, but it wouldn't surprise me if you lose some points. I have the B&S assignment, and it has a similar findByCriteria(String[] criteria) method. Even though the client will only have the ability to search by Name or City, my method has the functionality to search by any field, or combination or multiple fields. I think this falls under the "future functionality enhancements" clause in the instructions:
Your user interface should be designed with the expectation of future functionality enhancements, and it should establish a framework that will support this with minimal disruption to the users when this occurs.
However, it does not say must anywhere, so I doubt it would be an automatic failure.


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Paul Bourdeaux:
I don't think you would fail the assignment, but it wouldn't surprise me if you lose some points. I have the B&S assignment, and it has a similar findByCriteria(String[] criteria) method. Even though the client will only have the ability to search by Name or City, my method has the functionality to search by any field, or combination or multiple fields. I think this falls under the "future functionality enhancements" clause in the instructions: However, it does not say must anywhere, so I doubt it would be an automatic failure.

I'm having trouble interpreting the Javadoc for that findByCriteria method. Could you give me a skeleton or some pseudocode with how you approached the issue?
Eric Chang
Ranch Hand

Joined: Jan 27, 2004
Posts: 113
What I did is implement the find method the way the included comment says it should be implemented, in that I can search on any field or combination of fields based on the criteria using the startsWith method. However, my requirements state that I can search on the Name and Location fields using the criteria and that the criteria must EXACTLY match the values stored in the record. Therefore, after some researching on this matter using this forum, the ideal solution for me was to use JComboBoxes which are populated with valid values. However, should the developer of the client wish to allow searching on part of a field, then they could do that in the future without any changes needed for the find method.
Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
I had a drop boxes with the all option , and options for selecting the different choices in the database. I also had clear buttons so that user could clear the fields, and the blank fields did an all search as well, as the requirements stated. In this way the user could either chose the different options or type in the search and the program would perform and exact match. I thought the exact match requirement screamed for a drop box so I put one in. I got full marks for the GUI with my approach, you should add what ever feature you think will help the user, just dont over complicate it.
[ January 07, 2005: Message edited by: Inuka Vincit ]

MCP (C# application dev 70-316) 860<br />SCJP 1.4 100% SCJD (URLyBird) 378<br />MAD 100% nuts
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Inuka Vincit:
I had a drop boxes with the all option , and options for selecting the different choices in the database. I also had clear buttons so that user could clear the fields, and the blank fields did an all search as well, as the requirements stated. In this way the user could either chose the different options or type in the search and the program would perform and exact match. I thought the exact match requirement screamed for a drop box so I put one in. I got full marks for the GUI with my approach, you should add what ever feature you think will help the user, just dont over complicate it.

[ January 07, 2005: Message edited by: Inuka Vincit ]

Thank you both for responding, Eric and Inuka. I, too, took that approach with the GUI and made JComboBoxes, one populated with Contractor names and another populated with Contractor locations. My question, though, was aimed more towards the search method itself in the data class. Here is what the Javadoc says for the find method:

// 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".)

Currently, my search method is completely based on searching for a contractor name and/or location, and I know that I will probably get points off because you cannot search for anything besides those. I am having a brain lock where I cannot figure out how to implement the method given the comments listed above. So would the criteria always be an array that has a length of 6? Such as:

Is that correct? Say someone wanted to search by contractor name and price. Would the String array be:

That doesn't seem right because according above, it would match all of the values for location, etc. because they are all null. Am I completely missing something? Help!
Inuka Vincit
Ranch Hand

Joined: Aug 10, 2004
Posts: 175
No each field of the array corresponds to a column in the table. So that way it wont display all the fields

for example

to search java hilton
this is an example from my head carnt remeber what the specs said

search[0] = null //corresponding to rooms
search[1] = null //corresponding to date
....
search[4]= "java" //correspons to location column

...
search[5]="hilton" //correspons to name column

I think your thinking its search[0] or search [1] or .... search[5] type of thing. Rather its name== search[5] and location ==search[4] and ... search[0]== rooms type of thing(conceptually). Hope I dont sound confusing.... thats how I did the implementation and interpreted the requirements. Otherwise yes the search would be meaningless
[ January 08, 2005: Message edited by: Inuka Vincit ]
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by Inuka Vincit:
No each field of the array corresponds to a column in the table. So that way it wont display all the fields

for example

to search java hilton
this is an example from my head carnt remeber what the specs said

search[0] = null //corresponding to rooms
search[1] = null //corresponding to date
....
search[4]= "java" //correspons to location column

...
search[5]="hilton" //correspons to name column

I think your thinking its search[0] or search [1] or .... search[5] type of thing. Rather its name== search[5] and location ==search[4] and ... search[0]== rooms type of thing(conceptually). Hope I dont sound confusing.... thats how I did the implementation and interpreted the requirements. Otherwise yes the search would be meaningless

[ January 08, 2005: Message edited by: Inuka Vincit ]

I'm still a bit confused, I almost may need some sort of code snippet to grasp what you are trying to explain by your implementation. Here is my currently incorrect implementation of my find method:


I hope my incorrect implementation can help you understand how I am interpretting it incorrectly so you can help me. Thanks, Inuka!
David Abramowicz
Ranch Hand

Joined: Dec 10, 2004
Posts: 56
I've got a question regarding the omnipotent JComboBox. Do you guys perform a search everytime the JComboBox is touched before the values are displayed?

I'm just worried that otherwise the JComboBoxes wont have the latest data.

Thanks /Dave
Matt Sheehan.
Ranch Hand

Joined: Oct 08, 2004
Posts: 63
Hi Daniel,
I think its best to simply compare the two String arrays without thinking about which field is what. Like in this method:

You could use something like this in your findRecords method. A criteria example for name and location would be {"name", "location", null, null, null, null}. Then if you later decide you want to add search functionality for other fields, you won't have to change this code.
Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Hi, Jason! Not related to your question but perhaps useful... When searching for all records, I sent only the null parameter, if I remember correctly, as the array; this allowed me to short looking for all records and made their retrieval much faster than if i sent an array of nulls.


Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181

You could use something like this in your findRecords method. A criteria example for name and location would be {"name", "location", null, null, null, null}. Then if you later decide you want to add search functionality for other fields, you won't have to change this code.[/qb]<hr></blockquote>

Matt, thanks that helps. I was totally making it much harder than it should be and I implemented it correctly now. Anton, your idea of passing a null array sparked an idea. Thanks!
[ January 08, 2005: Message edited by: Daniel Simpson ]
Daniel Simpson
Ranch Hand

Joined: Sep 02, 2004
Posts: 181
Originally posted by David Abramowicz:
I've got a question regarding the omnipotent JComboBox. Do you guys perform a search everytime the JComboBox is touched before the values are displayed?

I'm just worried that otherwise the JComboBoxes wont have the latest data.

Thanks /Dave

Hey, Dave. I'm not exactly sure what you are asking. Let me try to answer my best of what I think you are trying to say. I have B&S and my specs says that it should allow a client to search for a contractor name AND/OR a location. I only have 2 JComboBoxes, one for names and the other for location. I am using a cache for my records, so at startup, my records are cached and the JComboBoxes are populated. I decided that repopulating the JComboBoxes after every call to update would require a pretty extensive algorithm the way I implemented. I decided that it is past the scope of the assigment since the only thing that is changing are the booked fields, nothing else. Another possible answer to your question, a client can select either name and location, or they can do both or leave both empty. When they hit search, a search is performed first on the server side to return wild card values (startswith) and then in my Controller in the GUI, the results are sorted again using .equals(). I hope that helps!
David Abramowicz
Ranch Hand

Joined: Dec 10, 2004
Posts: 56
That was exactly my concern, your first answer. So if contractors or locations are added during execution they will not appear in the JComboBoxes.

Hmm... I wonder if I'm happy with that, although I see your "past the scope of this assignment" argument.

Cheers /Dave
Josh Allen
Ranch Hand

Joined: Jan 15, 2005
Posts: 37
Originally posted by Matt Sheehan.:


Have you thought about not using like so, this would be the more common idiom:

 
wood burning stoves
 
subject: URLyBird Search Options