Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Thomas Thevis
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jethro Borsje
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roman Yankin
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic