Correct code/unit testing (was Re: Efficient python programming...)
Aahz
aahz at pythoncraft.com
Mon Jun 10 12:15:34 EDT 2002
In article <3D03CDD2.78C01DE1 at engcorp.com>,
Peter Hansen <peter at engcorp.com> wrote:
>
>The nastiest bugs were found by lots and lots of work, which usually
>included repeated attempts to reproduce the problem, manual runs,
>and sometimes using a debugger. Staring helped little. And then,
>having found the bug, we look at the code and say "oh yeah, we
>should have seen that."
Not necessarily.
>Better not to put the bugs in the code in the first place, however,
>so staring or those other things won't be necessary. Writing the
>tests and the code together, tests first, in small iterative steps,
>tends not to lead to buggy code. The payback is high compared to
>staring.
Maybe. The most difficult bug I recall tracking down turned out to
involved a web page created by a program that put a null character at
the end of an URL, like this:
<a href="http://www.example.com/foo/bar.html\x00">
Except, of course, that looking at the page's source in the obvious ways
didn't display the damn thing. I finally used Python to download the
page and display chunks of the pagestring. The problem was compounded
by a bug in MS SQL Server that considered the null-ending and
non-null-ending versions of the string to be either duplicate or unique,
depending on the precise operation.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"I had lots of reasonable theories about children myself, until I
had some." --Michael Rios
More information about the Python-list
mailing list