• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What if search criteria is null?

 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I return null in the criteriaFind method, if search criteria is nul??
I have been returning all records in the database if the criteria is empty string.
Thanks
Padmaja
[ June 12, 2003: Message edited by: Padmaja Prasad ]
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it depends on what you need: it's reasonable not to return anything or throw a IllegalArgumentException, IMO.
M
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it depends upon your implementation. I am assumming that you have drop downs for your select criteria you would put a wild card search element in there. If that wild card is selected what would you want to do? Build a search criteria like (key=,) or not build a criteria at all. If you choose to not build a criteria at all when they select your wild card search than I would say the answer is return all of the records.
If you select to build the search criteria than a null criteria should throw some sort of exception.
HTH
-Amish
 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max and Amish,
Thanks for the reply.
Amish, I have created ComboBoxes for selecting the search items and the criteria is constructed in the Client GUI. But I wish to keep the Data as generic as I can. It should handle all the conditions even though such conditions may not occur.
Thanks
Padmaja
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Padmaja,
There are two things going on here. The first is that you're allowing people to search for null through the gui: you may or you may not decide that this is appropriate. The second is that your remote object, facade, etc., are supporting such a search. I'm not sure that I agree that you should have two levels of validation. After all, if the validation changes, do you want to have to support both?
Better, IMO, to refuse a null search at the remote object layer, and validate against it @ the gui layer.
M
 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
Thanks for the reviews.

There are two things going on here. The first is that you're allowing people to search for null through the gui: you may or you may not decide that this is appropriate.
The second is that your remote object, facade, etc., are supporting such a search. I'm not sure that I agree that you should have two levels of validation. After all, if the validation changes, do you want to have to support both?
Better, IMO, to refuse a null search at the remote object layer, and validate against it @ the gui layer.
M
My GUI does not allow null criteria. Thanks for the ideas.
Padmaja
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max, Padmaja,
If there is null criteria, I am returning all records, and if the criteria does not match, I am returning zero elements from search and not null (like Collection containing no elements, or new long[0], etc).
Am I right Max?
Where Facade pattern is useful Max? Can you please throw some light to me?
Thanks n Regards,
Ganapathy.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your approach is reasonable, though I'm a little confused by the which facade pattern question: Can you decorate your question a bit?
best,
M
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
I have seen few postings here in this forum. They discuss Facade pattern in their assignemnt.
Do we really need to use Facade in this assignment? I went through the Facade, it is needed if developer want to provide single interface for a group of objects. Like collections class in java,util, where is has some algorithms. Also in case of static factory, Facade is applicable.
Is this assignment really that complicate, needs to provide Facade? Can we really justify the level of complicacy for Facade, is my question of concern.
[I followed the assignment given in your book closely. I am using parts of it, not code to code copy. It has provided reasonally good approach to develope the project. But design point of view, I liked Simon Robert's Complete Java Certification book. Both are equally good books, one in implementation, and another in developing assignment in your own way.]
Regards,
Ganapathy.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi S,


I have seen few postings here in this forum. They discuss Facade pattern in their assignemnt.
Do we really need to use Facade in this assignment? I went through the Facade, it is needed if developer want to provide single interface for a group of objects. Like collections class in java,util, where is has some algorithms. Also in case of static factory, Facade is applicable.
Is this assignment really that complicate, needs to provide Facade? Can we really justify the level of complicacy for Facade, is my question of concern.
[I followed the assignment given in your book closely. I am using parts of it, not code to code copy. It has provided reasonally good approach to develope the project. But design point of view, I liked Simon Robert's Complete Java Certification book. Both are equally good books, one in implementation, and another in developing assignment in your own way.]
{/QUOTE]
People sometimes use the term "Facade" to indicate a level of abstraction between one layer and another: effectivity a driver class, if you will. If that's what you mean, then yes, I think it's a good idea to use them in this assignment.
Just as an FYI, I also like Simon's book. It's not really a matter of which book is 'better', IMO. It's simply a matter of voice you're more comfortable with. Or, as seems to be the case for you, which combination of voices.
ALl best,
M
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Max,
Thankyou verymuch for your reply.
Regards,
Ganapathy.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"{/QUOTE]"
Those dang braces.
Mark
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see the chief smartass has fully recovered from JavaOne
M
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic