文章导航PC6首页软件下载单机游戏安卓资源苹果资源

pc软件新闻网络操作系统办公工具编程服务器软件评测

安卓新闻资讯应用教程刷机教程安卓游戏攻略tv资讯深度阅读综合安卓评测

苹果ios资讯苹果手机越狱备份教程美化教程ios软件教程mac教程

单机游戏角色扮演即时战略动作射击棋牌游戏体育竞技模拟经营其它游戏游戏工具

网游cf活动dnf活动lol周免英雄lol礼包

手游最新动态手游评测手游活动新游预告手游问答

您的位置:首页精文荟萃软件资讯 → Debugging ASP - Part 1: Debugging by Insertion

Debugging ASP - Part 1: Debugging by Insertion

时间:2004/10/7 19:15:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            By Tom Parkhurst

The debugging process can be painful for both novice and seasoned
developers alike. The next three newsletters will cover the basics of
debugging ASP code. While I can't promise that the methods I'll
describe will ease the pain, they will get you through the effort with
far less bruises.

Debugging can be boiled down to one simple phrase: Got a bug, find the
bug, fix the bug. Defined as any unplanned and/or unexpected result,
a "bug" can take the form of a blatant VB Script error popping up in
the browser window or something subtler, like the transposition of two
database fields?contents. Any time the implementation does not match
the design, considered it a bug.

Not to say that all bugs are necessarily bad things. When encountering
a bug that prevents the implementation from matching the design, ask
yourself: "Do I really want to fix it?". The oft abused phrase, "It's
not a bug, it's a feature!", should sometimes be taken seriously. If
what you actually built seems good, then perhaps you should
advocate "for" it rather than "fix" it. I have done this often with
good results.

When a bug really must be fixed, two possible scenarios generally
unfold:

1. You know your code so well that you immediately know what to fix
and where to fix it. Usually, a VB script error identifies the
problem and its location. Wouldn抰 it be a beautiful world if
all debugging were that easy?

2. In the more common debugging scenario, you don't have a clue.
The rest of this discussion will address this case.

Sound code design is the key to successful debugging. Modular code,
which separates functionality into small subprocedures and functions,
shortens the debugging cycle considerably. Functions and subroutines
present distinct pieces of code that can be tested and verified
separately.

One standard debugging technique temporarily inserts a Response.Write
in a function or subroutine抯 first line displaying the parameters that
were passed in. A matching Response.Write displays the results of the
function before you return. In fact, inserting temporary
Response.Write statements is the primary debugging method used in ASP.
A rather simplistic approach, but it works and provides immediate
feedback.

For example, I have inserted Response.Write statements into the
following function code.

Function calculateTax( fltCost, intZipCode)
Response.Write( "Entering calculateTax(" & fltCost & "," &
intZipCode & ")" )
...
(Lots of code that searches database for zip code, extracts %,
and calculates tax)
...
Response.Write( "Exiting calculateTax = " & calculateTax )
End Function

The two Response.Write statements provide all of the data that is
passed in and returned from the function. As a side effect, the
inclusion also verifies that the function is actually called -- many
times the key to the bug.

The drawback of debugging by insertion is that you must return to the
code and remove the Response.Write statements before releasing your
code. A better approach would be to create a method for turning these
display statements on and off as needed. Next week, we will discuss
expanding debugging by insertion to implement code tracing that can be
enabled or disabled through flags.

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本