I like metaphors. They have a very powerful way of telling a story. I think it is the very graphic nature of most metaphors I like.

Still, you can overuse, over analyze or put meanings into them which the audience does not understand or agree with. With that said, please have an open mind when reading the following. It might be a useful metaphor or it might not work at all for you.

When I heard of refactoring the first time, I was not really sure what the person was talking about. I was pointed to a book. Marting Fowler’s – Refactoring: Improving the Design of Existing Code. I like reading so I read the whole book and it was a real eye opener. I still had a hard time explaining to others what refactoring was and it was even harder to explain why it was essential that you did it. And kept doing it. All the time.

Tetris, everyone has played Tetris. Or looked at someone playing Tetris. It is so popular you can find it in cellphones these days. If you have ever tried it I want you to imagine the sliiightly stressing feeling you get when the pieces starts coming down very rapidly and you do not have a clue where to put them. The time you have to put the falling piece in an optimal position is so short, that even the slightest hesitation will put you in an even worse position in just another second. Can you feel the stress come crawling?

Where is that restart button …

Programming is very much like playing Tetris. You squeeze in pieces here and there. Trying your best and after a while the puzzle gets harder and harder. Software development and programming do not have a restart button though.

I once gave Tetris to a person I know. This was years and years ago so it was on a floppy and a week went by without me hearing anything. Naturally I wanted to know how she liked it. So the next time I met her I brought it up.

– “Did you like it. I mean the puzzle game I gave you?”
– “Yeah, sure, it was great … it was a bit hard though.”

Knowing this person I felt something was not quite how it should be. So, out of curiosity I had to dig a bit deeper and I needed to know what was hard. It’s not that hard … right?

– “What do you mean … hard?”
– “After a while the pieces are coming so fast and I can’t really seem to make them … disappear. They just clog up the field”
… long pause ….
– “You know, you can make the pieces rotate …”
– “Really, you can?!!!”

A week later the success she had with Tetris, and the fun was at a whole different level.

When you introduce refactoring to a person you are doing them a huge favor. You are in fact telling them that ‘the pieces are rotateable’. You are introducing a powerful tool to make code easier to understand, maintain and extend. By telling someone how and when to use this tool you are giving them an opportunity to enjoy programming even more.


About Ola Ellnestam

Agile Coach, Systems developer, Agile Practitioner and father of three.

3 responses »

  1. Jocke Holm says:

    It sure works for me. How lovely! Much better (and more fun) than “cleaning”.

    Come to think of it, is it more a metaphor of refactoring before changing the design than after-the-fact refactoring? Because you change the parts before you add the new part.

    Anyway, I like it.

  2. Ulf Jonson says:

    Hi Ola,

    “How to refactor safely is yet another important lesson. More on that later.”

    Ok, I’m waiting for a nice metaphore for the suite of tests that we could put our fate in 🙂

    Say hi to Tobias and Daniel.

  3. […] This post was mentioned on Twitter by Ola Ellnestam. Ola Ellnestam said: @tofo Reminds me of a blog post I wrote some time ago: http://is.gd/kkdcJ […]

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 )

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