Wednesday, June 8, 2016

Keep Calm and Debug!

Programming is exhilarating. From imagining how you want a program to behave, to actually getting the program to behave in the way you want, is a journey of highs and lows. In the end, when you have the expected output, it does give you a high, a feeling of satisfaction. There have been times when I was feeling slightly depressed/low but felt much better when I was able to find and fix a bug in the code. At other times, I have gone from being energetic and happy to slightly depressed/frustrated just because I got stuck somewhere and was not able to get things to work as I expected. Depending on how other factors are playing in your life, programming can be an emotional experience.

When I was a younger, relatively inexperienced programmer, the frustration would come out on the computer. The choicest expletives were hurled at the computer because it would not work the way I wanted it to! "Why doesn't you work the way you are supposed to, you @#$&#$#@$*&!"

As I became more experienced in programming, I became cognizant of my emotional reaction in such situations. A computer is always going to work the way it has been programmed. If something isn't working, its probably because I made a mistake. Some times, the cause was not reading the documentation of a library properly. At other times, it was encountering a new way of doing something. I may have never come across this approach before and thus my mind was resistant to learn a new way of doing something. By reacting emotionally to such issues, I was taking the focus away from the core issue. If things are not working, then someone has to be blamed and who better than the computer.

Over the years, I have become more calm, collected and rational in how I approach such issues. By being cognizant of the fact that it is more likely that I made a mistake or misunderstood something, I can keep my emotions away and calmly analyze the situation objectively for what are the possible mistakes I could have made. I have noticed that when you are calm and objective, error messages seem to make more sense. Thus keeping emotions in check helps in being a better programmer.

Apart from keeping emotions in check, another thing that I have noticed which helps in being a better programmer is to think what is really happening behind the scenes. Over the years, as I developed a better understanding of how different systems/libraries work, I feel I have become a better programmer.

How? I now try and narrow down the root cause of the issue as much as possible. Very early in my career, I would just try various solutions which I found online. I do that even now, but to a lesser extent. I try to lower the amount of guess work that I do and try and think logically about what is going wrong and where. The reason this is important is because you also lower the chances of introducing new bugs. Something was not working, so you guessed and changed something. Still not working. You changed something else; still not working. You found a bug and fixed it. Still not working. What!? But you just fixed the bug!

Yes, but you introduced new bugs due to the two changes that you tried which did not work. So your program still does not work as expected, even though you found the bug which was originally causing it. By eliminating guess work, you probably would have found the original bug earlier and not introduced the new one.

This is something that I also told the younger team members at Babajob, when they would throw up their arms in frustration when something didn't work the way they expected.

So , Keep Calm and Debug!




2 comments:

  1. Great and useful article. Creating content regularly is very tough. Your points are motivated me to move on.


    SEO Company in Chennai

    ReplyDelete
  2. Your blogs relate to me at a personal level and thus, are always interesting reads. I also believe they will gather much more traction on Medium because many of the blogs on Medium also are very personal.

    Keep posting new content!!

    ReplyDelete