Tuesday, January 28, 2014

Debugging: The Art of Loosing Your Mind!

If you're a coder, you know what the title means...  If you're not, this post is not for you.

Debugging is essentially trying to fix some code that does not work.  You know what goes in, you know what should go out.  But the results are not those expected.  It should be easy as every instructions are written in front of you.  You just have to find where the numbers do not add up as it should...  Wrong!

Trying to find an error in more than 100 000 lines of code is like trying to find a friend in Montreal.  You know where he's been, you know where he should be heading but you just don't know where he is...

Figuring out what's wrong requires a lot of concentration.  Especially when the issue does not generate an explicit error on the screen. Sometimes, it can be data that is wrong, sometimes it's a matter of logic, sometimes it's the regional settings of Windows that gets in the way.  You never know where to look, you never know what is the "real source" of the issue right from the start.

With time, you discover better ways and workarounds to find the source of the infamous bug, but often, it's a matter of trial and error until to nail it.

When we were young, we were playing this little game that goes like this:
- When I go to the grocery store, I put in my little basket...  a carrot...
- When I go to the grocery store, I put in my little basket...  a carrot... a cake
- When I go to the grocery store, I put in my little basket...  a carrot... a cake... some rice...

And on and on.  Each player has to add a new item to the basket, after reciting to whole grocery list.  Miss one item and you loose.  The last one who stands, wins.

This is a fun game, but it does require a good memory.  How far can you go?  12 items, 30 items, 100 items...  If someone talks to you as you are trying to recite the complete list, you will loose your concentration and probably miss an item or get it in the wrong order.

Debugging is worse than that game.  You have to remember 1000 items, in the order they occurred, with the weight, colour, price and their supplier.  Sometimes, you can't pause the list if it's going to fast and you have to start all over again.  Then someone interrupts you to ask about when it's will be fixed as they are in a hurry...  Again, you have to start all over again.

You take notes, so you won't forget where you were only to find out later that you don't remember what those notes really meant as they are now out of context.  So you need to start all over again...

This is debugging:  Remembering a really long list of interactions happening in real-time and trying to understand what is happening before it happens.

Next time you see a coder holding it's head, fully concentrated on his screen, stop!  Don't break his concentration, don't interrupt his mental process because he may have to start all over again, for the 10th time.

No comments:

Post a Comment