Roy Blyth on optimization

Posted on February 5, 2004
Filed Under /dev/null/ | 171 views |

Rory “Neopoleon.com” Blyth on when to optimize code, using a potential interview question as an example:

Before knowing what the string reversal function was going to be used for, and before knowing how often it was going to be used, these guys were pumping out more and more complex (and fragile in some cases) versions of the function.

As someone interviewing for the position, this would worry me to no end.

Now, what if I had approached the app with the intention of squeezing every last bit of performance out of it from the get go? Without being able to test the app, and without any profiling, I’d be coding blind - maybe spending hours to save milliseconds, and ignoring the real bottleneck which could very well be elsewhere.

That would suck.
- Optimization (not always a good thing)

He makes excellent points that have often been made before by others but tend to get forgotten by developers hell-bent on obsessing over the performance of single functions.

I prefer the extreme programming approach: write it to work, then refactor if you have time, then refactor again, and if you’ve still got time well, you’re probably working in the ivory towers of academia so what the hell, refactor that puppy once more. And don’t forget to profile all the way.

Comments

Comments are closed.