Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another Question about findByCriteria

 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody,

Basically, these are the requirements related to the findByCriteria.

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.

// 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 long[] findByCriteria(String[] criteria);



The method from the interface seems almost useless to fulfill the GUI's because the logic are different. The method is supposed to return all which value begins with criteria, but the GUI is supposed to return all that has exactly match values.

Do I have to call the method multiple time and do filters on the results to fulfill the GUI requirement? Have I missed something here?








 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,

Did you check this thread already?

Kind regards,
Roel
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Hi Jack,

Did you check this thread already?

Kind regards,
Roel


Yes, I have. But it is so weird... the idea that you have a db interface that contradict the GUI requirement.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Nam wrote:But it is so weird... the idea that you have a db interface that contradict the GUI requirement.


That's one of the points of this certification: how you deal with ambiguities in a project.
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:
Jack Nam wrote:But it is so weird... the idea that you have a db interface that contradict the GUI requirement.


That's one of the points of this certification: how you deal with ambiguities in a project.


It makes me feels like a lawyer reading a contract, not a developer with solving real problem mindset.

Anyway, I am pretty much done with the DB access class. Hope I got it right.

Thanks for the input.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,

Look it from another perspective. Imagine the interface you have to implement for this assignment is also used by another program which expects startsWith-matches. So not to break that application (and not to have to re-engineer this one) the contract has to be exactly the same. The usergroup of CSRs has decided they want their application to work with exact matches. Such a scenario can happen in real world, without a doubt.

Kind regards,
Roel
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,

This requirement is only slightly ambiguous in my mind. Doesn't the word "Freddy" start with the letters "F-r-e-d-d-y" ?
Aren't the letters "F-r-e-d-d-y" an exact match for the word "Freddy" ? I'm not sure I see a problem here. Of course, if you're searching for "F-r-e-d", you'll find "F-r-e-d-d-y" also. The specification doesn't say only exact matches.

Harry
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gotta say to Roel, you make a really good case. You opened my eyes a little bit there

Sorry for hijacking this thread with only to say that

/Peter
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harry Henriques wrote:Hi Jack,

This requirement is only slightly ambiguous in my mind. Doesn't the word "Freddy" start with the letters "F-r-e-d-d-y" ?
Aren't the letters "F-r-e-d-d-y" an exact match for the word "Freddy" ? I'm not sure I see a problem here. Of course, if you're searching for "F-r-e-d", you'll find "F-r-e-d-d-y" also. The specification doesn't say only exact matches.

Harry


It does.

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.
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Hi Jack,

Look it from another perspective. Imagine the interface you have to implement for this assignment is also used by another program which expects startsWith-matches. So not to break that application (and not to have to re-engineer this one) the contract has to be exactly the same. The usergroup of CSRs has decided they want their application to work with exact matches. Such a scenario can happen in real world, without a doubt.

Kind regards,
Roel


It could, but not likely. It would be better if the test is solving-problem oriented, instead if reading-carefully-n-must-follow. It is less fun.
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,

I took a graduate course in Computer Language Theory at Boston University.
It is possible that I didn't quite understand the material, but I think that I do
understand it. I think that it is possible to state the following:



Stating something "exactly" matches something else, is not the same
thing as saying "only exact matches".

Harry
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harry Henriques wrote:Hi Jack,

I took a graduate course in Computer Language Theory at Boston University. It is possible that I didn't quite understand the material, but I think that I do understand it. I think that it is possible to state the following:



Stating something "exactly" matches something else, is not the same thing as saying "only exact matches".

Harry


Hi Harry,

I am shitty computing school graduated and English is my third language (no sarcasm) .

To me, "exactly match values specified", means A=B and B=A. I could be wrong though.



 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Champions, the thing is, in the Data class, you use the startsWith() method. For each field of a record, just check if it starts with the corresponding value in the String array received as parameter (and this is for each record in the database). In your GUI, you verify if the entire word provided by the user matches the values returned by the Data object (for both and/or search), and for this, you can use either equals() or equalsIgnoreCase() (just don't forget to mention this choice in your choices.txt file). So you'll still have to filter the values returned by the Data object before showing them in the UI.
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,

If you feel that you can defend your position in your choices.txt document, then implement the solution as you understand the specification. All you are required to do is defend your understanding of the specification. I understand your position. It isn't completely without merit. I interpreted the specification differently than you are interpreting it. I also implemented my SCJD assignment according to my understanding. Since I haven't received my results yet, I don't know if my interpretation is defensible. I suppose I could be FAILED for not implementing the "must" requirement in accord with the specification. Time will tell...

Harry
 
Jack Nam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto Perillo wrote:Champions, the thing is, in the Data class, you use the startsWith() method. For each value in the String array received in the find() method, just check if the value of the record in position n starts with the n value in the String array (and this is for each record in the database). In your GUI, you verify if the entire word provided by the user matches the values returned by the Data object (for both and/or search). So you'll still have to filter the values returned by the Data object.


Thanks for the assurance. That exactly what I m gonna do.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Jack! Please note that I edited a little bit the post while you were quoting the previous one!
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it better style to use the String-methods startsWith() and equals() or is it better to implement matching making use of regular expressions?
Which one of those techniques is preferred over the other when grading is regarded?
At first I decided to use reg ex. On the one hand it looks very elegantly but on the other hand it implies much more lines of code making it also more difficult to read and understand. So I am not sure if voting for the simple stratsWith() comparisons is actually the better choice?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jack Nam wrote:It could, but not likely. It would be better if the test is solving-problem oriented, instead if reading-carefully-n-must-follow. It is less fun.
I already had to deal with such situations. And that is exactly what you have to do in real world: the business gives you (through a functional analyst) some requirements and you have to implement them. It is not your task to implement other requirements, because you thought that would be more fun.

@Harry: when you use the code-tags make sure you format your code (max 80 characters per line for example). could you edit your post, so the rendering of this thread can occur without horizontal scrollbars ?

@Jack: could you edit the post where you quoted Harry's post (for the same reasons).

Andy Jung wrote:is it better style to use the String-methods startsWith() and equals() or is it better to implement matching making use of regular expressions?
I just used startsWith() and equals() methods from String class, because they just do what is needed for the assignment. So no reason for spending extra (development & testing) time to build a custom solution.

Kind regards,
Roel
 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel & Roberto,

It looks like I didn't understand the specification the way it was intended to be understood. Is it more likely that the assessor will FAIL me or will s/he just deduct points? What has happened in the past? Should I anticipate a FAILURE outcome, and re-submit my work again now, or should I wait for the result?

This is really a very easy part of the specification to implement. I could probably code this requirement in an hour (with testing).

Thanks,
Harry Henriques
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harry,

First of all thanks for editing your post.

You should always wait for the result, no need to re-submit your assignment before getting the result. If you fail, you will get an explanation why you failed and you can adjust it. I don't think you will fail for having another implementation of searching, maybe get some point deduction. But I recollect only failures, when the locking mechanism wasn't implement correctly.
How to search for hotels/contractors in gui and data class is one of the most questioned topics of the assignment and a dozen of possible implementations are already submitted (if you read all the stories of people passing this assignment), none of these guys (and girls) failed. So no need to worry if the rest of your application (locking, networking) is ok. I'll expect you'll soon be a SCJD.

Kind regards,
Roel
 
Allan Cheong
Ranch Hand
Posts: 71
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The requirement in The User Interface section states 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.


Literally, it did not state that it is a must for the searching to search for exact values. However, it is a must to allow for the user to perform a search in the GUI level.

Arguable?

I have jarred my submission. I do not want to make any changes to the code anymore. Otherwise I need to rebuilt the entire project - javadoc, source code, choices.txt, userguide.txt. I am now just waiting to book the essay exam time before sending e-mail to Sun to request for permission to upload the file.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Allan,

Literally, it did not state that it is a must for the searching to search for exact values.
I am not a native English speaker, so I'm wondering how the sentence from the instructions should look like if it is a must to search on exact values?
Because my interpretation was "a must requirement to search on all records and records with exact matches for name and/or location".

Kind regards,
Roel
 
Allan Cheong
Ranch Hand
Posts: 71
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm.. I am not a native English speaker myself too. I've changed my mind. I think I should do the exact search in GUI level.
 
Daniel Breitner
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 interpret this as follows:

The User must be able to search for exact matches. When only the interface from db (which uses startsWith) is supported, the User is only able to search for exact matches if he types in the complete name of the room to rent.

For example : Lighthouse

But what if there is another room called Lighthouse2 ? Then the user is no more able to search for an exact match.

On the other way round, there is no requirement stating that the User should be able to do a "fuzzy" search

=> This leads to the assumption, that the best solution is to implement the server like the DB interface says with "startsWith" and then filter out (in the GUI or business implementation) all those that are no exact matches.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,

Please, do not cross post!

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic