Saturday, October 13, 2007

Programming Lesson: You Are The Bug...

There are a few things that inspire you, that make you think, that give you a new outlook. Somethings that help you introspect. And programming for me has always been the combination of all of the above things. Programming is what you could call, my way of praying or praising God.

This post is not completely technical, but I'm somehow compelled to share it with all my colleagues, friends, students and all those who read my blog. And I add some analysis for my project teams, so they start believing that software is equally philosophical as much its technical.

Programming Lesson 1: You are the bug. You are the solution

There was once a monk who would carry a mirror where ever he went. A priest noticed this one day and thought to himself "This monk must be so preoccupied with the way he looks that he has to carry that mirror all the time. He should not worry about the way he looks on the outside, it's what's inside that counts." So the priest went up to the monk and asked "Why do you always carry that mirror?" thinking for sure this would prove his guilt. The monk pulled the mirror from his bag and pointed it at the priest. Then he said, "I use it in times of trouble. I look into it and it shows me the source of my problems as well as the solution to my problems."

A lot of developers are great at writing code. They are really good at getting the results. A lot of people whom I've taught programming think that getting the desired output is the goal of writing programs. Thinking objectively is great when you want to finish the project, but when the bugs start calling, thinking philosophically is the best thing to do. And the first step is taught by this story!!

Realizing that the bugs appeared in the program, due to some thought process during the time of writing the program is the first step to improve as a programmer. I always ask everyone to have a bookmark of what's coming to mind when problem solving. The bookmark can be either on a piece of paper or in your mind. Later, whenever you find bugs, try to correct the thought process first and then the code. Understand that you have written the bug yourself, and "Unlearn the Learning". Forget all that you know about the program and start over again on the module with a different thought process!!

My reflective mirror on programming is the JavaVM/OS (with garbage collection) which I had written for my BS project. It ran Java programs on a microcontroller with 8KB memory and I implemented a robot on it. It was my masterpiece of art but it's a mirror that tells me I have to build things that are useful/understandable not just to me, but others.

You can have your own reflective mirror that tells you what you do wrong. Use it positively and learn from the good things and not so good things that "you thought"*, you created!!

Update: This was initially supposed to be a single post with 7 stories, but I realized that its going to be longer than comfortable to read all the posts. So I'll continue with a new post for each story

Part 2 - Lesson 2: Switch Off-Switch On

* - thats a different philosophy all together

2 comments:

Namrata said...

Wow! While reading this I remember what u used to tell me while teaching. My reflective mirror tell me to think like u, to learn like u. Before u taught me,I used to bring desired output only. But u taught me to think about process first & then code. Because of that I have improved my Programming.

Saptarshi Purkayastha said...

Thanks for the flattering reply!! I have a lot more to learn as well... Like I heard somewhere, I only know as much as the grain of sand and there's the whole beach to learn!!