Akash. As we know in the real world, things like performance can and should be a requirements basis. Meaning, if I am creating a new application, I want to know up front what are the speed/performance requirements and make sure that my algorithms meet those requirements.
However, in the SCJD assignments, there are no such requirements. So by changing the search to be a binary search might speed things up a little, it isn't necessary for the assignment.
If for your own benefit, you want to see if you can implement it, then do so, but I wouldn't include that bit of code in the submission.
A clear design, such as will be readily understood by junior programmers, will be preferred to a complex one, even if the complex one is a little more efficient. Code complexity, including nesting depth, argument passing, and the number of classes and interfaces, should be reasonable.
[Philippe]: Well, if do_this, do_that, this_happens and do_something_special processes are never called in another context than complex_stuff, I do prefer the second way of coding, even if complexStuff() is bigger. Simply because do_this, do_that (...) code chunks are far more difficult to read and understand if they are decoupled of their running context. In Delphi or PL/SQL I would have used nested procedures in such a case, but while waiting for Java 3 or 4 , I would code this as you do.
I am pretty sure (and hope so) that Andrew will have a comment to do here.
search algorithm: clarity and efficiency (15)
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Originally posted by James Hook:
I see that you have used the String Tokenizer to split the String up..
but what if the criteria string takes the form?
FieldName='sgjhgdsj,gjgjhg=dfgjgjhfdg'
has anybody else used regular expressions to check that the criteria is valid?
[Mark]: You will be wasting time if you want the most efficient and fastest code.
[James]: has anybody else used regular expressions to check that the criteria is valid?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Philipe, I see in your commentary of the code
that you are worried that a large data set would flood
the available memory of the JVM.
Given that the return type of of criteriaFind method is DataInfo[], is there any way of streaming data back to the caller?
Think I may investigate throwing an exception if this happens. Or is this overkill because the db.db file is so small anyway?
It's a tiny ad. At least, that's what she said.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|