Thursday, June 12, 2003

Optimization - It's All the Rage

Quite a few people have been talking about optimization lately. Notably Sam, Don, and Tim. I particularly like what Tim has to say:

1.      Design and code your app, trying hard not to do anything really stupid, and striving for flexibility.

2.      If it’s fast enough, don’t worry any more.

3.      If it’s slow, get out your profiler and measure things until you understand where the problem is.

4.      Fix the problem, which may well require major refactoring, but that’s OK because that’s probably coming at you pretty soon anyhow with the next batch of requirements. Furthermore, you couldn’t have avoided it because nobody is smart enough to predict where the bottlenecks will be in a complex application before it’s running.

I can’t even count how many times I’ve seen people ask questions on the mailing lists that show they’re trying to optimize their system at a micro level before they’re even done coding. It’s soooooo tempting – I find myself constantly fighting the battle with myself (and last week, with my coworkers). I often lose. And then I find something like this is the slowest thing in my application.

Why do we do this to ourselves? Is it because we measure our professional worth by how cleverly we program? Is it because CS degrees have at least some focus on algorithms?


  1. Well the why is easy. Most developers are obsessive about detail. This is of course what makes it possible to code, but it sometimes (often?) gets out of control. It just goes with the territory.

  2. You've probably nailed it. Certainly I know I have a tendency to get down in the weeds when I should be looking at the big picture.

    In fact, you may have hit on the key to another issue I run across frequently: the disconnect between "architects" and "developers". Perhaps "architects" have the reverse problem: they won't look at the trees for envisioning the forest...

  3. Rather OT, but talking of architects and detail. We are renovating an office building to occupy, and I am horrified by how little details architects (the physical building kind) provide. Recent weeks have been spent resolving power point/radiator conflicts, doors (direction, handles, kick plates, letterboxes) and myriad other details.

    This had got me thinking about obsessive detail when I saw your comment.