Debugging
  1. Debugging intro
  2. Debugging basics
  3. Debugging errors
  4. Debugging find errors
  5. Debugging best practices
  6. Debugging tools
  7. Debugging summary

Debugging basics

When debugging, it's important to know when to expect errors, what kind of errors to expect, and what to do when errors occur.

This tutorial focuses on:

When to expect errors

You should expect errors whenever you are writing code (for any language). Computers do exactly as they're told, they don't know if you made a mistake or not. If you made a mistake they function on that mistake assuming that's how it's supposed to be.

Always watch out for errors, but be extra cautious when your code starts getting more and more complex. Complexity increases the chances of errors because more is going on and there is more of a chance of something not working as intended. There is a much higher chance of an error if you have 500 lines of code as opposed to 20.

Have patience

Debugging is not easy and requires patience. As sometimes the errors are obvious and sometimes they are more subtle. You can spend 2 minutes debugging something or you can spend 2 hours. Have patience, you will find those errors and fix them :)

Type of errors

There are several types of errors you will run across when writing code.

Javascript code with some syntax errors:
var message = "Javascript is cool var message2 = So is HTML" alrt(message1) alert(message2

Seeking help

There are several sources from which you can seek help if you're having a hard time debugging.

Yourself

Trust in yourself to be able to find the errors. Check out our finding errors page if you are not familiar with the various methods used to find errors.

Search engines

You can copy and paste the error that's generated and search based on that criteria to see if anyone has discussed that same error on a webpage before. You can also type the name of the language you're working in together with a description of the error. Example - "PHP can't access form data"

Forums

Errors and how to fix them are often discussed on forums, particularly when it comes to errors that derive from the code of web software like ZenCart. If you are dealing with errors in an existing web software, you are most likely to find help in the forums for that particular software. Solutions to other errors can often be found on forums too.

Visit our debugging forums where you can discuss debugging with others.

Co-workers

If you work as a web developer together with other web developers, why not ask your co-workers for some help? Be nice about it - ask them if you can have a bit of their of time on something you're working on, show them where the problem is and it is likely that they will try to help you.

© Copyright 2013-2014 Landofcode.com
Terms of use | Privacy policy | Copyright information