| << 9.5.1- The GetLastError Method | Chapter9 |
Summary
You can clearly see that debugging and error handling in the world of ASP is not fraught with the problems that you might have thought. With a little careful planning and a simple set of rules to follow, it can be made even easier. Here are some of the simple rules that you should follow:
- Use Option Explicit. This saves huge amounts of time looking for typing mistakes. Remember to take it out of your scripts after the page has been successfully debugged otherwise it could degrade performance.
- Reuse code where possible, by use of sub routines and include files.
- Don't get confused between client-side and server-side script.
- Use sensible variable names. This helps prevent confusion as to what the variable is for.
- Comment your code. A lot of experienced programmers joke that if it was difficult to write, then it should be difficult to read. That's just an excuse for laziness. Try to provide code for others to read that you would like to read yourself. If you're worried about the slower processing of a commented page, then why not keep two versions: one version with comments for development and documentation and a second version without comments, for use in the production environment.
The script debugger provides a very useful tool, which can make locating and testing errors that much easier. Also, the addition of an ASPError object, in ASP 3.0, means that errors are reported in a more detailed and comprehensive way in ASP 3.0.
If you've done any programming before, you've probably realized that ASP programming is not that different from any other type of programming and that you need the same range of skills. You need to plan ahead and be prepared to think laterally when errors occur, as the problem isn't always where you think it is.
| << 9.5.1- The GetLastError Method | Chapter9 |

RSS

