User Control Panel
Advertisements

HELP US, HELP YOU!

Basics on program bugs

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Tutorials
View unanswered posts
Author Message
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sun Nov 16, 2003 3:42 am    Post subject: Reply with quote

Many of you are very new to programming and want to jump right in to writing a bot, without having to spend too much time learning syntax, etc. You also may not have all the tools that an experienced programmer has, such as a debugger.

There are several types of bugs:

syntax errors: You left out a semicolon or closing brace, for example. When you get syntax errors in your programs, the compiler or interpretor will usually give you a file and line number of the problem and most of the times, tell you exactly what is wrong.

crashing bugs: You tried to print an undefined value, for example. Your application crashes at runtime and exits. You also usually get a file and line number, but the error may be more obscure.

obscure bugs: Sometimes you get a file and line number, but the bug happened earlier in the program and the line number you get is simply where it finally failed. For this type of bug, usually code worked earlier but it did something incorrectly or unexpectedly. For example, a string split created a string and empty string instead of two strings as you expected.

For this last type of bug, the best thing to do is work backwards from the line the program failed on. Pepper your code with print statements, print out the values of variables, see if you are getting what you expect to get, print out arguments to subroutines. As you go further back, eventually you will find the line that caused the bug. Fix that. Leave the print statements in. Make sure all the values are what you expect and then start to remove prints. You'll be surprised at how well this works. It may seem tedious, but it's actually very fast.

As you become more experienced, you'll realize it's a good idea to put prints in as you develop code so that you catch bugs early in the development process, rather than have dozens of bugs later.
Back to top
Keenie
Almost An Agent
Almost An Agent


Joined: 31 Oct 2003
Posts: 1071

Reputation: 52.4

PostPosted: Sun Nov 16, 2003 3:59 am    Post subject: Reply with quote

well done Mojave Smile
This should come in use (hopefully) for beginners
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Tutorials All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group