Efficient python programming...
Steve Holden
sholden at holdenweb.com
Sat Jun 8 16:18:11 EDT 2002
"Peter Hansen" <peter at engcorp.com> wrote in message
news:3D013FB1.3D7477EA at engcorp.com...
> Roman Suzi wrote:
> >
> > On Fri, 7 Jun 2002, Peter Hansen wrote:
> > > You forgot the even more important first thing for a beginner:
> > > get it correct! The only good way to do this is to write unit
> > > tests that prove it. If you don't have tests, you don't have
> > > working code (or how can you prove it?).
> >
> > To prove that code is correct is very difficult (practically
impossible).
> > Unittests are there to prove that you have errors, not the other way
> > around.
> >
> > Of course, they can increase your confidence in that optimized code is
> > equivalent to what you had before.
>
> I disagree, if the tests are written first (and run, proving that
> they will fail when the code is wrong or missing).
>
Clearly a test that succeeds when the code is demonstrably wrong is an
incorrect test. But a test that succeeds when the code *isn't* demonstrably
wrong doesn't guarantee the code is correct. Most tests aren't complete
enough to guarantee that the tested code runs to specification over all
possible inputs.
Please don't think I'm arguing that test-before-code is bad - I think it's
great, and very helpful for collaborators.
> The tests are executable requirement specifications. Running
> them "proves" (yes, not 100%... nothing could) that the code
> meets the specs. The specs could be wrong of course, but that
> doesn't mean the code is broken...
>
That's pretty much where I fall out with the formal methods crowd (who
invaded the academic world in the 1980's, putting paid to some of *my*
fun...). They don't seem to realise that for practical development projects
all they really do is replace bugs in the implementation with bugs in the
specification, since the specifications become mathematical notations
incomprehensible to the average user. Ultimately it's the users'
requirements that must dictate the specification.
regards
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------
More information about the Python-list
mailing list