Home > Computers and Internet > Code Review design and performance decisions

Code Review design and performance decisions

An important lesson for every programmer to learn is that you should build beautifully first, and then find the performance issues. A solid design/algorithm will do more for performance than squeezing out a couple of clock cycles here and there. The idea being that when you’re writing the program, do so in a way that expresses your intent, and if it’s found to be inefficient it’ll get fixed (perhaps made less readable) later.

While I love Linq I know through my own testing that it does cause applications to slow down. If something took 100ms before, it’ll take 115 ms with Linq. That by itself is not a big deal, and totally justifies more expressive code. The problem is the death by a thousand cuts situation. Little inefficiencies everywhere can make performance less than desirable.

I was code reviewing a coworkers code the other day and saw a typical pattern of iterating over a collection and setting a boolean to true if an item met a certain condition. I suggested he call the Any extension method on the collection because it expresses his intention better. After making the suggestion though I could foresee that exact suggestion being undone. The reason is that the location of that code was in one of the more performance sensitive parts of the code. So in the near future we could very well be doing performance analysis of our code and see that Linq method was taking to long and we need to change the code to what it was originally doing.

So while I don’t mind coding for readability in the first place, the idea that later I’ll be hunting down to undo a suggestion I made in a code review bothers me.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: