• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Doubt in the implementation of criteriaFind() method

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am new to this group. I am just started implementing the assignment. I have a following doubt ::
In the assignment it is given that, from GUI user should be able to
select the origin and destination of flights, and the display should
update to show only flights that satisfy criteria. It is also given
that Origin or destination or both can be "any"(to satisty wildcard-
like feature).
Here nothing is mentioned about carrier.
But in the instructions of criteriaFind method ------>
public DataInfo[] criteriaFind(String criteria)
It is given that parameter(criteria) of above method must be of the
form....
"Carrier='speedyAir',Origin='SFO'"
Here Destination is not given.
I am little bit confused here, in design of GUI and even
implementation of criteriaFind() method....whether to include only
Origin and Destination...Or should I include carrier also at both
places???
I am assuming of passing paramether to criteriaFind method in this
form....
"Carrier='SpeedyAir', Origin='SFO', Destiantion='DEN'"
Is criteriaFind() depends on carrier field or not???
I will be glad if anyone clarifies my doubt.. especially
those who already certified in SCJD or those who crossed this
phase...
Thank u ..
jpro ch
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jpro,


I am little bit confused here, in design of GUI and even
implementation of criteriaFind() method....whether to include only
Origin and Destination...Or should I include carrier also at both
places???


I and I feel most have provided for Origin and Destination because they are explicitly spelled out in the requirements and also Carrier because, as you pointed out, it is implied in the example.
You can't go wrong by using those three criteria on you client GUI.
You need to design your criteriaFind() method so it will take any valid field/value pair based on the current database schema though.
Hope this helps,
Michael Morris
 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The criteriaFind must be generalized to accept any number of parameters however from the point of view of this assignment it would suffice if you could provide for three drop downs on the client gui for the user to select the origin, destination and carrier and parse the criteria and pass it to criteriaFind method.
Thanks
Ravinder
 
jyothi sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Micheal & Ravinder,
Thanks for ur quick reply..
Yeah Ravinder, I desingned my GUI & even criteriaFind() method (Taking origin,destination & carrier into consideration) in the same way as u said..I hope this will be correct..
But Micheal, I didn't understand clearly what u said..i.e
You can't go wrong by using those three criteria on you client GUI.
What does that mean?? what, we should take carrier into account?? any way I did take that in to consideration.
More over in the assignment it is given as..for both origin and destination the value can be "any"..there also nothing mentioned about carrier.. What about u guys?? Did u assigned "any" value to carrier also or not??
Ofcourse I didn't assigned...Is it correct??
but for user that will be useful...
Like this..
"Carrier='any',origin='SFO', destiantion='BOM'"
From above user can get all the filghts between SFO & BOM . From which user can select one, based on price, timings, day, available seats...
What is ur opinion..? please guide me in correct direction if I am wrong.. But I am also thinking that we should not provide any additional features which r not given in requirements..
I just started my assignment..I have much to do..If u both r already finished or about to finish the assignment, I need ur suggetions..
One more question, Here in this forum I did go through some messages. In those, some r saying that they used Design Patterns in the design of assignment. I don't have any experience in the java Development. I didn't hear them(Design Patterns) till now...What exactly they r?? Can suggest me a best book/link on that...
And one more... I can develop assignment in local mode(I know sequence of steps here)..but for assignment to work in network mode, what & how should I do/follow??..I am planning to use RMI...
I am looking forward for ur reply..
Thank u all...
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Jpro Ch"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jpro,


What does that mean?? what, we should take carrier into account?? any way I did take that in to consideration.


Yep, that's what I meant. Sorry for the confustion.


More over in the assignment it is given as..for both origin and destination the value can be "any"..there also nothing mentioned about carrier.. What about u guys?? Did u assigned "any" value to carrier also or not??
Ofcourse I didn't assigned...Is it correct??
but for user that will be useful...
Like this..
"Carrier='any',origin='SFO', destiantion='BOM'"
From above user can get all the filghts between SFO & BOM . From which user can select one, based on price, timings, day, available seats...
What is ur opinion..? please guide me in correct direction if I am wrong.. But I am also thinking that we should not provide any additional features which r not given in requirements..


You should design your criteriaFind() in such a way that the "ANY" option doesn't matter. You should never pass a criterion into criteriaFind() that is set to "ANY". If you start with the assumption that all records match and then remove all records that don't match the passed criteria then "ANY" takes care of itself.


In those, some r saying that they used Design Patterns in the design of assignment. I don't have any experience in the java Development. I didn't hear them(Design Patterns) till now...What exactly they r?? Can suggest me a best book/link on that...


The classic is Design Patterns Elements of Reusable Object-Oriented Software by Eric Gamma et al. Here it is on bamm.com: Design Patterns


And one more... I can develop assignment in local mode(I know sequence of steps here)..but for assignment to work in network mode, what & how should I do/follow??..I am planning to use RMI...


You should design local and remote together. Create a common interface for both and work from there. Don't think of them as separate, just different in how the get to Data. For the remote server, do some searches on ConnectionFactory. That's the best place to start. Then you can start filling in the holes as you go.
Hope this helps,
Michael Morris
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is another simple question.
Requirement does not mention about how to handle the Zero seat. I mean do we need show the flight with zero seat into the table when user do the search/criteriaFind? It doesn't make sense to me.
Thanks!
Patrick
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Patrick,


Requirement does not mention about how to handle the Zero seat. I mean do we need show the flight with zero seat into the table when user do the search/criteriaFind? It doesn't make sense to me.


I labored over the same question. But after the wise counsel of Mark, I decided to include them. Like Mark pointed out, its like going to a web site and seeing some product like a book or concert ticket that is currently unavailable. There may be some in an hour or two due to cancellations, who knows? Its better to go ahead and show what might be available as well as what is actually available. Besides, if you try to book the last seat on a flight and some other client gets it ahead of you, do you really want that record to just disappear from the table? That might be confusing to the user.
Hope this helps,
Michael Morris
 
jyothi sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u Micheal..
I will look in to that book(Design Patterns).
If I get a doubt at any phase..I will come to u...

Jyothi
 
Patrick Li
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Michael,

Don't know whether somebody posted this one or not. I just go ahead to post it.
I try to implement criteriaFind in two way:
one is triple loops and another is like this:
first, parse criteria String and put the name-value pairs into a map called searchMap.
second, get field names and values from a DataInfo(one record in db.db) and put all field name-value pairs into a second map called recordMap,
last, then do a subset like:
if (recordMap,.entrySet().containsAll(searchMap.entrySet()))
matched = true;
by using System.currentTimeMillis() to compare the two implementations based on limited record in db.db, the triple loops outperforms the map. but triple loops code is very hard to read and map way is easier to code and understand.
I don't know prove which algorithm is better theoretically and don't have enough data to prove it. Could you give some thoughts about this? Thanks
Patrick
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Patrick,


first, parse criteria String and put the name-value pairs into a map called searchMap.
second, get field names and values from a DataInfo(one record in db.db) and put all field name-value pairs into a second map called recordMap,
last, then do a subset like: ...


That's pretty much what I did and the code is simple and clear. Don't worry about the performance issue on using an alternative loop or recursive method. First rule is always get it right and make it clear before ever considering optimizations.
Hope this helps,
Michael Morris
 
Patrick Li
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, Michael.
I am happy to know that I am not too away from right track.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic