Asier's thoughts

Blogging about software development

Beware of optimisation


In my short career as a developer I have heard many many times the word optimisation and I am already sick of it…

  • You have to optimise your code so it runs faster.
  • Do not use an ORM, just write SQL in your code. If  you use store procedures even better! You have to optimise!
  • We will add all of this extra attributes in our objects. We don’t need them right now, but we will do in the future. Is more effective doing it now that having to change the code in a later stage.
  • We need to create a caching system in our application so we optimise the times we access to the database.
  • etc.

At first you will think all of this is good. Why don’t we want to optimise? Optimisation is good, really. Makes our systems faster, better! Doesn’t it?

Well yes and no. We should be careful with optimisations, they add extra complexity to our systems, and we should aim for simplicity. Before optimising you should ask yourself: Do I really really really need that optimisation??

More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason – including blind stupidity.

W.A. Wulf

If you want to optimise check first the benefit you will get from it.  You shouldn’t be optimising without measuring.  Use a profiler and measure it. Is it still worth it? If yes, go for it.

In my case, I try to avoid optimisation as much as possible, do that decision as late as possible. Don’t  worry, when you really need it, you will optimise!

Rules of Optimization by MA Jackson:

Rule 1: Don’t do it.
Rule 2 (for experts only): Don’t do it yet.

2 thoughts on “Beware of optimisation

  1. Pingback: KISS – Keep It Simple Stupid « Asier's thoughts

  2. Pingback: Clean Code Development: Red Grade « Asier's thoughts

Leave a Reply

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

You are commenting using your 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