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

Wildcard 'any'

 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
this is from my spec. :
The user must be able to describe enter the string value "any" for the origin, destinatin or both, so as to implement a wildcard-like feature.

My english is not very good, and I am not sure about the "describe enter"
I used comboboxes to select the airports...and the user can 'select' any...Is that ok or he should be able to 'enter' any?
daniela
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did it the sameway as you did.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is everyone implementing this wildcard with the criteriaFind function anyway?
I see that many are defining their criteriaFind method to recognise the magic value "ANY". When I did the assignment, I rejected this as an ugly solution --- given that "ANY" in the criteriaFind string is equivalent to not having the criterion at all, it is really hard to justify its presence in the criteriaFind API.
Rather, when building the search in the client I would recognise the value "ANY" and simply not add that field to the criteriaFind string. This doesn't only lead to a simpler criteriaFind implementation, it also makes for easier i18n (internationalisation). This "ANY" magic word obviously differs from language to language. It seemed to me therefore that it ought to be the user interface recognising it, not the server.
Obviously, i18n is way outside the scope of the assignment. But whenever I'm getting greater flexibility or elegance without adding any complexity, I take that as a sign that the design has improved.
- Peter
 
Jai Karuppuswamy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My criteriaFind implementation is exactly like Peter's.
And in my UI, I made the combo box enabled, so that the user can type in any, if he/she wanted to search all flights. But I am wondering if I should show any as a selectable value in the combo box, instead. I looked at the Java UI guidelines and to me it looks like both are acceptable. Is one option preferred over the other? If yes, why?
Thanks.
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have planned (yet to implement!) to put 'ANY' in the combo box and the user may type in 'ANY' too. But criteriaFind() does not know what is 'ANY'.
The Client will format ANY as an empty ''. The CriteriaFind() would know '' as 'ANY'.
Is this idea acceptable to Peter and others?
Rajesh
 
Daniela Ch
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I handle the wildcard value in the gui and only send the selected airport (or empty string) to the facade, then in the facade i construct the criteria...
I wanted to be able to change the wildcard value easely (in the gui) and I did not want the gui to bother with the formating of the database...
it is done in two steps...
bah
i am uploading today
 
Bernhard Woditschka
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I choosed the following version:
The CUI combobox includes "any".
This will be translated to null for the models getFlights(String origin, String Destionation)
null values then are simply ommited criteria in the call to criteriaFind() i.e. not present in the query string.
Bern
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajesh Rajesh:
The Client will format ANY as an empty ''. The CriteriaFind() would know '' as 'ANY'.
Is this idea acceptable to Peter and others?
It's more relevant whether it's acceptable to the assessors, which it probably is. Is it the most elegant solution? Well, how will you ever find records that contain an empty String? And why have the magic value '' where you can achieve the same effect by simply not including that field in your criteriaFind expression?
- Peter
 
aadhi agathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter, i have got a question? what if he is saying Origin='ANY' and nothing else . if you are not sending in to the criteriaFind, how will it be going to display the results.
-Aadhi
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aadhi agathi:
what if he is saying Origin='ANY' and nothing else . if you are not sending in to the criteriaFind, how will it be going to display the results.
My implementation needed no special code whatsoever to deal with this situation. The client would call criteriaFind(""), i.e. with an empty criteria String, and criteriaFind() would return all records in the database because every record would satisfy the criteria supplied (none).
- Peter
 
Aruna Raghavan
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
I do the search only if at least one criterion is entered. In a real-life app, we don't want to return all database entries, do we?
Aruna.
 
Brian Blignaut
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a requirement to use a combo box? I simply have two text fields for origin and destination where the client can type in the criteria?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Blignaut:
Is it a requirement to use a combo box?
No. It's nice to have, and the assessor may like your UI better if you use them; I don't know. But it's certainly not a requirement. (I used plain text fields, BTW).
- Peter
 
aadhi agathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tx Peter, i got it!
-Aadhi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic