in reply to Optimisation isn't a dirty word.
Which one do you use? The answer, of course, is "it depends." If X is some cronjob that runs once a month, it doesn't really matter if it takes five seconds of background process time, so there's no point in wasting time writing the hard version. On the other hand, if X is some calculation that must be executed thousands of times per day by users who need immediate feedback, then the one-second version is clearly preferred. And finally, how likely is it that X will change? Chances are the inefficient algorithm is more general and the efficient one more fragile.
Optimization is important -- but it's equally important to know when to optimize and to know what to optimize for.
|
|---|