• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to impl search

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
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
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic