 | 
October 3rd, 2008, 02:26 PM
|  | Moderator | | Join Date: Dec 2006
Posts: 4,745
| | A Simple Debugging Guide
Congratulations! You are one of the few who realise that over 80% of errors are simple and easy to fix. It is important to realise this as it can save a lot of time. Time that could be wasted making unnecessary changes, that in turn can cause further problems.
Programming is a humbling experience. An experience that causes one to reflect on human error. One major cause of these errors is syntax, syntax, syntax. We tend not to notice when we have made a typo. It is too easy to spend an hour trying to fix a problem that was caused by a typo. Accepting human error, that you made a mistake, is a reasonable first assumption.
Another important assumption to fixing problems is Occam's razor - the simpliest explanation is more often than not the best. When we initially expect a simple error we don't try to over complicate things and we are more likely to use basic techniques to trap the error; we use simple debugging procedures.
Sometimes just writing a message is enough to see what is going on. One easy technique is to trap the error in a try catch block and write the error message. Its surprizing how often this simple technique is not used.
In asp.net there is a custom errors mode remoteonly. What this does is display the exception only on the local server, but anywhere else. Other users of your application may be directed to a customized error page, while you figure out what's going on.
A very important step to avoiding errors in your application is testing. This is best done on a separate machine to the development and production servers. Even if you don't have access to a test environment this is no reason not to test. We developers are not the best testers. Get someone else or preferably a group to test, believe me you'll save time and probably money.
One of the most common errors is the 'object reference not set to an instance of an object'. Null reference errors are common too. Something, a reference or a parameter for example, is missing. So check the page references and parameters. Look in that error line to see what may be missing or null. Write any values that may be null.
A simple thing that you can do is continue to practice. Programming in an unfamiliar language is slow to start with, but experience is cumulative. As you get more practice, things like error handling become easier. It doesn't become easier if you just copy & paste all the time, there is no substitute for understanding what's going on.
There are many debugging techniques, but that is not the point of this article. Its not until I started to appreciate the number of my errors and the simplicity of fixing them, that I really started to make progress. At times I am still guilty of skipping the diagnosis and heading straight for the medicine cupboard. This has almost always been a mistake.
I hope that you avoid some of the frustrations that I have had over the years by not ignoring human error and accepting how simple steps can resolve most problems.
Happy programming!
| 
November 13th, 2008, 12:54 PM
| | Member | | Join Date: Mar 2007 Location: Bangalore, India Age: 28
Posts: 110
| |
Well, thats a beautiful write up!
You are certainly right in almost all the places. Human errors are trivial and the impacts created are more.
A fact not to forget is, "We learn by mistakes" :). But we should ensure that "mistakes are NOT repeated" -- thats when we call it as an experience!
Cheers,
Raghavan alias Saravanan M.
| 
December 25th, 2008, 05:57 AM
| | Newbie | | Join Date: Dec 2007
Posts: 16
| |
Thanks for the nice article. Good encouragement for beginners like me who are afraid of bugs. there is no substitute for understanding what's going on.
This is my most favourite line of the article.
Thank you,
Rajesh V.
| 
February 23rd, 2009, 07:58 AM
|  | Newbie | | Join Date: Dec 2008 Location: ijug.net
Posts: 10
| |
What I have found is keeping a note of what all steps you took , what all did you observe also help a lot to debug difficult bugs.
| 
February 26th, 2009, 04:37 AM
| | Moderator | | Join Date: Oct 2006 Location: Australia
Posts: 7,750
| |
Hi.
I'd just like to point out what (ironically) looks like a typo in the article. To quote... Quote: |
In asp.net there is a custom errors mode remoteonly. What this does is display the exception only on the local server, but anywhere else.
| At a guess, there's a "not" missing there.
| 
April 17th, 2009, 01:52 PM
|  | Newbie | | Join Date: Apr 2009 Location: chennai,India
Posts: 2
| |
thats so kind of you to make newbie's like me comfortable in programming.
sumtimes the problem is gruesome but at the most its due to simple things only
| 
June 3rd, 2009, 08:53 PM
| | Familiar Sight | | Join Date: Dec 2008 Age: 22
Posts: 191
| |
I was stopped for nearly three or four days in a program to count objects with specific color in an image, I did the whole code without change in approximately two hours but didn't work, after three days of just looking for what I have done wrong was a property that returns a different field's value (simply int).
It wasn't believable to me in first that I can fix a problem, It disappeared with some try and encourage thoughts like this.
Thanks, It was a nice article encourages much.
|  | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,662 network members.
|