wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: Does anyone care about find()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S: Does anyone care about find()?" Watch "B&S: Does anyone care about find()?" New topic
Author

B&S: Does anyone care about find()?

Thomas Thevis
Ranch Hand

Joined: Sep 02, 2008
Posts: 87
Howdy,

first of all, I used the forum'd search function and found a lot of threads dealing with the find() method. I'm sorry if I missed one already answering my question.
In my Bodgitt an Scarper 2.1.1 assignment I have to implement a database find(String[] criteria) method which supports prefix matching for each array index. The simple implementation would obviously be to iterate the complete database and perform a String.startsWith() for each record entry.
Obviously, this implementation does not scale very well.
In real life, I would add some kind of createIndex(int recordFieldIndex) method to my database which creates some sort of suffix tree as a Trie for instance. However, for the SCJD, such an implementation seems to be a little out of scope, don't you think?
Has anyone of you spent time on implementing a find() method which is at least a little smarter than the complete database iteration?

Best regards,
Thomas


SCJP 5.0, SCJD in progress
Jethro Borsje
Ranch Hand

Joined: Jul 22, 2008
Posts: 100
My requirements state that code simplicity is more important than performance, so I decided to just iterate over my entire db. I a solution using Trie is a bit overcomplicated for the SCJD.


SCJP, SCJD
Roman Yankin
Ranch Hand

Joined: Aug 27, 2008
Posts: 47
Well, I have implemented case insensitive search: fieldStr.toUpperCase().startsWith(...) and I believe it should be fine for the current task. First of all because there are many more things that deserve greater attention, secondly any other implementation would require greater complexity which is not welcome as you wont get extra points for extended, more reliable, more efficient or whatever functionality
Thomas Thevis
Ranch Hand

Joined: Sep 02, 2008
Posts: 87
Hey guys,

thanks for your answers. I think, I'll stick with a simple solution as well.
@Roman: Is this case-insensitive search something requested in your assignment? If not, don't you think that this is kind of risky in case your database access class is tested automatically?

Regards,
Thomas
Roman Yankin
Ranch Hand

Joined: Aug 27, 2008
Posts: 47
My assignment has no case specific requirements, as far as I know non of the assignments actually have anything like that. I don't think it is risky to do something specific unless you are asked not to do that, so even if some automated testing software fails because of this (which I highly doubt) it would not fail my assignment, most likely they would not even subtract points for this ... at least hope they would not, but really, this is not what I care much about
Thomas Thevis
Ranch Hand

Joined: Sep 02, 2008
Posts: 87
Got it. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S: Does anyone care about find()?
 
Similar Threads
Only fun forwards for fun ...
Need some feedback about "Harnessing Hibernate"
Using Thread ID for lock owner not safe?
Ant Colony System (Heuristic Search)?
Boggle search algorithm - How this works?