Wow you made it to the last and final lesson! Stunning. As a reward for all
your hard work, I've made this lesson extremely relaxing no nitty-gritty code to wrap your mind around and no hairy homework, just coding
theory and pointers to resources.
The topics for the day
are:
- Tools to help you write JavaScript
- Debugging
techniques
- Tips for making your JavaScript code run
quickly
Tools of the Trade
To tell the truth, I
don't use anything other than a word processor to write JavaScript. Call me
old-school crusty even. Though plenty of tools out there
write JavaScript for you, the code they generate is pretty
obtuse and difficult to change. If you really want to use a tool to create
JavaScript, I
suggest
Dreamweaver, which pumps out some amazing JavaScripts in very little time. However, if you
ever want to tweak the scripts later, be prepared to look at some awfully ungainly code.
You can also find tools that help you debug
JavaScript. I don't use these
either. Netscape has one, and so does
Microsoft, but I've never
met anyone who's successfully used these
debuggers. Go
ahead, prove me wrong. But until someone convinces me that
a product is worth buying (hint, hint, hint send
me that free software), I prefer to debug the old-fashioned
way.
Debugging Techniques
As you program JavaScript
more and more, you'll begin to understand
those opaque error messages
JavaScript gives you. And once you understand the common errors of your
ways, you'll soon know what pitfalls to avoid, and the raw code you
generate will be less and less error-prone. Programming is definitely a
skill that improves dramatically over time. But no matter how skilled you
become, you're still going to spend some time debugging.
If you've
been doing your homework, or have ever tried writing JavaScripts of your
own, you know that a considerable hunk of your scripting time is spent
debugging. This is normal it's just one of those things programmers have
to do. In fact, according to numerous studies, 50 percent of the average
programmer's time is spent figuring out what's wrong with code.
The key is to learn how to debug your programs efficiently. I
have several tips to help you figure out why your program isn't doing what
it should, or to avoid writing buggy code in the first
place:
- Print out variables in various ways
- Watch for
common mistakes
- Think before coding
Let's start with
printing those variables.
next page»