Friday, February 25, 2005

Software programming can be humbling

My experience has been that software programming can humble the most experienced programmer. You sometimes need a fresh look at the problem at hand and probably fresh eyes as well to debug a problem. Based on my experience, I am trying to come up with a simple set of rules that might help the programmer with his situation, these rules can be generalized so much so that it almost becomes common sense.

  1. Try not too hard to debug a problem, take a break, come back later
  2. Are you able to explain the problem you are seeing? Can you describe the pattern in which it occurs? Stop looking at the code and try to understand the pattern and possible explanation for it
  3. Use your friendly debugger or your friendlier console log messages
  4. Can you narrow down the problem to something simpler
  5. If you are dealing with numbers - think signed != unsigned
  6. Are you dealing with garbage data? Garbage data implies faulty pointers or storing more than the capacity
  7. Do you assert() the code (yourself) frequently enough
  8. Is this a recently created problem - look at what you changed recently
  9. Can you simulate what the computer is doing (if you can find the faulty logic in code) on paper or in your mind. If so, there is a good chance of you catching the bug
  10. Don't solve the same problem twice

I will keep adding to this list as I get more input from all of you or start thinking clearly.

2 comments:

Raffi said...

Few points from me:
1) If you can't figure out in 30 minutes, google it.
2) If you can't figure out in 60 minutes, raise hands for help to your colleage.
I have helped so many times and also got help so many times.

Balbir said...

Yep, good points.

I need to come up with a newer draft. But the thing is with google you can hit the following

1. You could hit patented/proprietary implementations - which is a potential landmine
2. You need to acknowledge and keep track of copyrights, etc

Ranking and Unranking permutations

I've been a big fan of Skiena's Algorithm Design Manual , I recently found my first edition of the book (although I own the third ed...