This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: case insensitivity (yes agian) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S: case insensitivity (yes agian)" Watch "B&S: case insensitivity (yes agian)" New topic

B&S: case insensitivity (yes agian)

Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 407

Cases insensitive searches or not with findByCriteria

yep i've read the other threads :-) I can see the issues with the user search in the GUI being specfied a bit ambiguiously and I'm ok with that (i.e. case insensitivity at the GUI, partial matches issues etc etc).

What more worries me is in the interface as I regard that as it should be exact in that I suspect they may run an automated testing tool. Can anyone confirm if they do this ?? in which case there would be an exact right answer.

i.e. I can't work out if their findBycriteria in the Data interface is case insensitive or not ....

... and if I program it the wrong way round (interface as opposed to GUI) they might just run a script against the interface and mark a fail
i.e. at least in the GUI (I intend to gives options to both in the GUI)
I can present preferences etc and justify my choices in the essay.

Also because of there restrictions on midifications to the Data interface presumably I can't put some nice 'proper' comments to explace my case insensitivity choice .

Its basically because of everyone elses auto fail horror stories that I'm concerned.

Any thoughts ? or has any one passed and knows which they implemented, again I understand about the real world scenario of bad specification but in the real world I would ask the customer ;-) and if I couldn't get hold of them take an educated guess.

"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Chris,

To be on the safe side I've implemented a case sensitive search in my Data class as the comments for the method provide a case sensitive example. (For example, "Fred" matches "Fred" or "Freddy".)

Therefore it should pass the requirement and any automated tests run against the interface.

The issue then is how you make the search usable in the GUI, people seem to have implemented two solutions, 1) provide drop down lists in the GUI for search criteria which negates the case sensitive issue, or 2) create an additional search method which supports case insensitive search which can be toggled in the GUI.

rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
I think the issue is not to see this assignment as an assignment, but as a real job given to you by a company, and you must make those decisions which are reasonable from that point of view. Because Sun wants to test your abilities in managing such real life situations.

Would you, given the job description, make the search case sensitive? I would not. I cannot think of a logical reason why a company would want a case sensitive search, and providing that description. Case sensitive searches are mostly not wanted by users, and if they would have wanted it that way, they could have stated that more explicitly. So chances are high that this is just an unintended unclear description without any underlying reasoning. I don't think Sun will sack you or take points if you make this case insensitive - just give a motivation.

_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Rinke,

I'm afraid I disagree with you here, this is not a real application, if it were we would challenge some of the requirements and implement the application very differently.

The aim is to pass the assignment, whilst learning along the way, and I would suggest the best way to do that is to keep everything as simple as possible and implement the requirements as they are, NOT what you would do in the real world.

The main area that Sun can automatically test is the Data interface, it is also the component that may be used by other applications, so I don't believe you can assume that you can just change the way the find method behaves, even if it doesn't make sense in the real world.

What I have suggested is two solutions for working around the issue whilst still implement the behavior as described by the method in the data class.

If you implement the drop down list approach, case sensitivity is not an issue, if you provide additional search method you are providing the ability for the user to search using the case insensitive option, but are still adhering to to method description.

For the sake of a few extra lines of code I think it's better to go for the safer option myself.

rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
Originally posted by Jason Moors:

The aim is to pass the assignment, whilst learning along the way, and I would suggest the best way to do that is to keep everything as simple as possible and implement the requirements as they are, NOT what you would do in the real world.

Hi Jason,

Of course it is different from the real world situation, because in the real world you would just communicate with the company and ask them "what do you mean by this".

However, on the other hand I don't think in practice it is very different from what you are saying. A company would be paying you for the job, and in order to keep costs reasonable, I think you should keep a job as simple as possible, within the boundaries of the specification. Otherwise the company would be paying for things the did not ask for. So in practice this approach is not different from what you are saying.

And I really don't think sun will lower you points for such a tiny issue as case sensitive or insensitive. As long as you motivate your choices, and the motivation I gave about real world issues is usually a good motivation - as long as it does not create much more work and difficult code. Which, in this case, it doesn't.
Cless Alvein
Ranch Hand

Joined: Jun 18, 2007
Posts: 39
I get the feeling that any doubts you may have can be explained in choices.txt. People have avoided implementing the 48 hour requirement (for URLyBird) and have passed as long as choices.txt noted that decision.
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
As there is no must be case sensitive criteria then it is really up to the interpretation of what is meant by exact match in the requirements. Of course if it was a real client it would be very easy to clarify this information.

I would tend to agree with Jason that case insensitivity is the best option at the level of the Data find method. The reason for this is that it is trival to wrap a case sensitive search function around the case insensitive find method. However if your Data find method is case sensitive then a case insensitive search could not be performed without modifying the Data class either by changing the find method or adding a new case insensitive find method.

In a very large real world project this could potentially be a very expensive change to make (Anyone remember the Y2K problem it was not totally dissimilar).
[ June 22, 2007: Message edited by: Mark Smyth ]

It is sorta covered in the JavaRanch Style Guide.
subject: B&S: case insensitivity (yes agian)
Similar Threads
Find requirement seems inconsistent. Help
NX: Will they think my GUI is too simple?
B&S - Some more questions according the database (see third post)
Meaningfully equal in equals()