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.