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?
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
Joined: Sep 02, 2008
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?
Joined: Aug 27, 2008
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