ÄúµÄλÖãºÊ×Ò³ ¡ú ¾«ÎÄÜöÝÍ ¡ú Èí¼þ×ÊѶ ¡ú 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’t 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’s 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¡ª¡ªÒ»¿îºÃÓõĵç×ÓÈռDZ¾