First do it, then do it right, then do it better

I was recently reading a writeup / interview on nettuts about Addy Osmani and there was one particular quote that resonated withy the way I’ve been thinking recently, “first do it, then do it right, then do it better”.

I wanted to get my thoughts down, and expand on this particular sentence, breaking it down and emphasising its importance when it comes to working on a new project (or indeed any piece of work).

First do it

It’s as simple as it sounds, like Nike says, just do it. Don’t worry too much if you’re doing things the best way first time around. I’ll give you the hot tip, you’re not. S don’t bother wasting time on trying to foresee the future and create the perfect solution right off the bat. Smash out your first version, as long as it works, that’s fine enough for now.

Then do it right

Now that you’ve got a working version, you can come back and refactor to get things organised and looking a bit more organised from that initial mess you made. Clean it all up, remove the dud commented out code, and rewrite your comments to be more helpful to your future self, you’ll thank yourself later.

Then do it better

Now comes the time to shine, this is where you prove to yourself that you really do know what you’re doing. This is where you take your reorganised, and neaten end up code and refactor it further, optimising your code to not only run as efficiently as possible, but also to follow the SOLID principles of design to ensure your code is much easier to work with, and much harder to break in the future.

Just don’t be stupid about it

This isn’t to be take too literally, in the first step, there’s no point in smashing out messy code for the sake of making messy code, particularly if that’s not your style in the first place. The goal here is purely to take the focus away from following conventions too strictly early on and getting caught up in red tape, but instead simply get some working code together to be able to prototype and continue to refine things from there, in sections.

If you spend too much time trying to get things perfect from the start, you’ll be burnt out well before you finish, and if you can’t code with passion, you shouldn’t be coding at all.

  • mars-o

    great article you have here. i’m still on the “do it” part right now, both in design and code :)

    • http://www.subooa.com.au Chris Duell

      the next part’s the fun part!

  • shoden

    By “do it” I’d say this is the prototype. Don’t refactor this. Just build it again from scratch. Just my opinion.

    • http://www.subooa.com.au Chris Duell

      I guess I was referring to building out the main first version.

      But I definitely agree if you’re at the prototype stage, build that, then when it’s proven, turf it and start the main build from scratch.

      • shoden

        Does your main first version include tests?

        • http://www.subooa.com.au Chris Duell

          It would, yes. In an ideal world, basic tests are written in the first step, and if need be, regression tests written for refactoring.

          You would take a different approach?

          • shoden

            Not at all. I was hoping that it was included.