Our next sin is the one that I've certainly been prone to.

Long ago my wife and I owned a house east of Renton, Washington (those who know about Renton at that time can probably understand why one would say "east of Renton").

Like many homes, this one had had various indignities committed on it by the previous owners. One of the most obvious was what can only be described as a "lean-to", constructed out of surplus Boeing shipping containers and shielding the washer and dryer from the rest of the garage.

After dealing with cold and dirty feet for a few months, we decided to convert the space to a real room, with features such as a floor, a laundry sink, a ceiling that was actually attached to the joists, etc. The framing went quickly, but when it came to the point of finishing the drywall, we ran into a problem.

My wife and I had very different ideas of how smooth a wall should be before it was painted. She wanted it to be mostly smooth, while I spent a fair amount of time with a light at an oblique angle, trying to get it really smooth.

I did the bulk of the drywall finishing myself in that room.

And after it was all painted, it turned out that it didn't really matter. Her standard was fine.

Which leads us, in the usual roundabout way, to our destination:

Sin #4 - Premature Optimization

Or, in other words, spending time on things that don't really matter in the end.

It's happened to all of us. You're in the middle of writing a class, and you think "a linear search of an array just isn't going to be fast enough here". So, you spend some extra time, and you use a hash table, or a tree, or a binary search, or something like that, and when you're done, you say to yourself, "now *that* isn't going to cause any problems".

And then later, when you're getting close to done, you run your code through a profiler, and you find that a) the array never has more than 3 elements and b) the code is spending a ton of time elsewhere in the code.

You wasted the time that it took you to do the optimization (bad), and you may have ended up with code that is considerably harder to read (worse), depending on how much optimizing you did.

How do you avoid this? I have two bits of advice:

  1. YAGNI came out of XP, and it's a good dictum to follow. If you are doing TDD, this is easier to do as you are more focused on making one small change and not on "finishing the class".
  2. Go read what a wise man has said about performance, and work on creating a performance culture in your group.