File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes GUI Search Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "GUI Search Question" Watch "GUI Search Question" New topic
Author

GUI Search Question

James Turner
Ranch Hand

Joined: May 10, 2004
Posts: 194
Hi all,

I have a quick question about the GUI's search capabilities. My instructions say:

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

I am assuming that the 'search the data for all records' means that the user can request all records to be displayed in the JTable and they will then visually browse through it.

Also the use of the word 'or' in saying that the GUI should allow the user to display all records and also search for records my name/location, i.e. both capabilities or does it mean implement either one exclusively?

If I was to provide both seach capabilities (get all records and search by name/location) would I be penalised for this? That is assuming I must implement either one exclusively!

Any help would be greatly appreciated.

Thanx

James.


James<br />SCJP 1.4 - 92%<br />SCJD - 93%<br />SCWCD 1.4 - 95%<br />SCBCD 1.3 - 100%<br />SCEA - 92%
Charlie Goth
Ranch Hand

Joined: Feb 26, 2004
Posts: 60
What do you think it means? As long as you can justify it (in choices.txt) you wont lose marks.

Charlie


SCJP (77%)
Jon Entwistle
Ranch Hand

Joined: Feb 20, 2003
Posts: 118
Hi James,

I took this to mean that we need to allow the user to search by criteria or return all records in the database, i.e. two search functions in the interface.

Regards,

Jon


SCJD, SCEA
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
hi James:
"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."

I interpert the previous statement as following:
Your search method should return a collection of records where:
1) record.deleteFlage == "0";//or what ever sign is used to identify a record as active
2) record.name == theGivenName;
3) record.location == theGivenLocation;
4) (record.name == theGivenName) && (record.location == theGivenLocation);
5) (record.name == theGivenName) || (record.location == theGivenLocation);


SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Hi everyone,

This is a perfect example of an unclear specification where you have to make a choice as to how you believe it should be implemented and then document that decision. As long as it is documented, you shouldn't have a problem.

My personal reading is that you can
  • search for all records
  • search for records matching provided name
  • search for records matching provided location (the or to point 2
  • search for records matching provided name and provided location



  • The nice thing is that the language is imprecise enough to allow my interpretation. And my solution is going to be easier to implement than Hanna's (although I acknowledge that Hanna's interpretation could also be correct).

    Regards, Andrew


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Julian Kennedy
    Ranch Hand

    Joined: Aug 02, 2004
    Posts: 823
    "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."


    The simplest interpretation of the above is that you either have to implement a search for all records or implement the more specific name/location search. However, I wouldn't want to take the chance of opting for that interpretation at the risk of losing marks on the usability of the application (even with justification for the design choice/cop-out).

    I think Andrew's interpretation is the most likely optimal solution as it is the kind of search capability that I've previously implemented in real-world enterprise software. Hanna's suggestion is equally valid, however, but contravenes the KISS principle (Keep It Simple, Stupid!). :-)

    I have a question related to this thread. My B&S spec asks for search functionality where the name/location EXACTLY matches the search criteria as quoted above. However, the comment description of the find() method in the DB interface states that: "A non-null value ... matches any field value that BEGINS WITH [the search string]". It also says that: "Your data access class ... MUST implement the [DB] interface", which would seem to be a bit of a waste of time given the stated user requirement. This apparent contradiction (or anomaly), while possibly intentional, makes me wonder if I should provide some basic pattern matching functionality for the user. Of course, in line with the aforementioned KISS principle, I'd rather not! :-) Any views?

    Regards

    Jules
    Anton Golovin
    Ranch Hand

    Joined: Jul 02, 2004
    Posts: 476
    "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."


    It seems to mean the following:

    Your user has to be able to:

    1) download all records for browsing.
    2) download all records where name exactly matches the respective value in the record.
    3) download all records where location exactly matches the respective value in the record.
    4) download all records where name and location exactly match respective values in the record.


    Also, if you read the comments to the DB file, it says that the

    public int[] find(String[] criteria)

    method must have its criteria[n] element also match those records where a partial match can be achieved. Since the top points speak only of name and location, I take it to mean that partial matches on those values are necessary as well.

    So I am probably going to implement the following:

    x = name, y = location
    x = null - all records match on x
    y = null - all records match on y

    if y == null and x matches partially (in this respect, a complete match is just a perfect partial match, so to speak), fetch the record.
    if x == null and y matches partially (in this respect, a complete match is just a perfect partial match, so to speak), fetch the record.
    if x == null and y == null, fetch all records
    if x != null and y != null fetch only those records for which there is simultaneous partial match (could be a perfect partial match) for both x and y.

    Because you are likely going to be checking for match with some method that checks if user input matches a substring from the beginning of a record field, you don't really have to worry about writing specific code for complete matches. You should only check for partial matches, and a complete match will be a particular case in that check.

    P.S. Yep, I agree with Julian, there is a contradiction in the instructions, and this would be the perfect case for documenting the choices. I think in some cases they deliberately provide vague or contradictory directions to account for real-life requirements. In this case, though, the method signature they provided does not allow for distinguishing between allowing partial search and requiring only exact search. So based on the provided method signature and their contradictory instructions, the only way to comply with both is, we must allow partial search, and I will put exactly this reasoning into my choices.txt when destribing my implementation of the search feature vis-a-vis their instructions.
    [ August 03, 2004: Message edited by: Anton Golovin ]

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

    Joined: May 24, 2004
    Posts: 783
    "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."

    My interpretation of this statement matches Andrew's, although I can understand how someone else could easily interpret it differently.

    Also, if you look at it from a user's point of view, it would make the most sense to be able to browse the entire database, search by name, by location, or by name and location.


    “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
    Walter Tang
    Greenhorn

    Joined: Aug 13, 2004
    Posts: 25
    Originally posted by Julian Kennedy:

    ......
    I think Andrew's interpretation is the most likely optimal solution as it is the kind of search capability that I've previously implemented in real-world enterprise software. Hanna's suggestion is equally valid, however, but contravenes the KISS principle (Keep It Simple, Stupid!). :-)
    ......
    Jules



    I believe they are different.

    In Hanna's suggestion:
    (1) search all records,
    (2) search only records matching the given name
    (3) search only records matching the given location
    (4) search records that matching both name and location
    (5) search records that matching either ( (1) union (2) )

    In Andrew's suggestion:
    doesnt have (5).

    In specification:

    ....where the name and/or location ...... which are case (4)and (5)

    Keep it sophisticated, smart (KISS)
    [ August 29, 2004: Message edited by: Walter Tang ]

    SCJP
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: GUI Search Question