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

How to impl search

 
Dave Teare
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,
I had a question regarding how the search should be implemented. In my instructions, it says I need only do complete matches, so I decided to do String comparisions only (as opposed to regex).
I implemented the method findFlights, which returns me a List of DataInfo objects to be used in the JTable. The method is brain dead simple, it simply iterates through the main list of flights and adds only those that match the criteria.
Do you think this is "good enough" for the exam? It seems incrediably inefficient. My plan was to say in the design choices document that performance was sacrificed for simplicity.

Thanks for your input!
-- Dave.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds perfect.
You just need to loop through all the records then get just the matches. You do not need to use regex since it is complete matches.
Mark
 
Dave Teare
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was hoping my implementation was okay; like your tag line says: Laziness pays off now
How would you recommend obtaining a List of flights to begin with? Should I simply read in all the records from the Data class everytime a user does a search? Or, perhaps I should load the information once on startup into a cache, and search it instead. Of course, I would then need to keep the cache in sync.
Any comments/suggestions?
Thanks!
--Dave.
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,
By all means, avoid a cache if possible. That's just added complexity you don't need.
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave all I did was call the criteria find with your all search, it always should return all records.
You don't need them to begin with, but if you want them you can do the above.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic