[Biococoa-dev] [BioCocoa] Speed vs Safety
jtimmer at bellatlantic.net
Sun Aug 29 18:36:18 EDT 2004
> A general discussion topic based on the emails from the last days.
> Koen asked John a few times, why did you do this while we can do it in
> one line of code, and the answer John gave was that he did quite some
> error checking and in general expressed his concerns about
> users/developers trying to execute malicious code.
> Personally, I'm impressed by the safety John builds into his code, but
> am worried that sometimes this goes a bit to far and might have the
> opposite effect. Let me explain.
Okay, just got back in from a weekend away.
You're right that I'm probably projecting the amazing and unexpected things
that users do to developers, hence the paranoia.
A couple of things to be said in my favor - I've tried to limit most of the
paranoia to situations involving either object creation or file input.
There's a couple of reasons for this. One is that, in comparison to memory
allocation or disk input and output, error checking's going to be time
inexpensive (all the tests for the tempDictionary didn't add any time that
was distinguishable from background noise to the DNA manipulations in the
demo_app). The second is that, if errors are checked for here, it's going
to be relatively difficult to introduce them later (though clearly, as you
note, not impossible).
So how about we make a deal - I won't complain if you remove my error
checking code from anything that doesn't involve initializing or disk-I/O,
and you don't complain about me putting them in those places?
> Ps. At WWDC's Cocoa optimization session we were told that in general a
> for(i=0; i < x; i++), where x is [theArray count] is faster and less
> memory intensive than an enumerator (no object messaging involved).
> Although the latter is definitely more elegant, if we are looking at
> speed bottlenecks with large sequences, this might be something to keep
> in mind.
Didn't know this - I'll take it into account in the future, and may go back
and modify some code accordingly.
Incidentally, the tempDict variable was used back when I did my nucleotides
with an "initWithDictionary:" method, and it didn't seem worth removing the
error test after I changed it to an "initWithSymbol".
This mind intentionally left blank
More information about the Biococoa-dev