This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Doubt in the implementation of criteriaFind() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Doubt in the implementation of criteriaFind() method" Watch "Doubt in the implementation of criteriaFind() method" New topic
Author

Doubt in the implementation of criteriaFind() method

jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
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


jyothi
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
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


SCJP, SCJD, SCWCD, SCBCD, SCEA
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
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...
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
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
Patrick Li
Greenhorn

Joined: Aug 30, 2002
Posts: 11
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Sep 11, 2002
Posts: 65
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

Joined: Aug 30, 2002
Posts: 11
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

Joined: Jan 30, 2002
Posts: 3451
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

Joined: Aug 30, 2002
Posts: 11
Thanks a lot, Michael.
I am happy to know that I am not too away from right track.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in the implementation of criteriaFind() method