Efficient python programming...

Peter Hansen peter at engcorp.com
Fri Jun 7 19:20:17 EDT 2002


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).

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...

-Peter



More information about the Python-list mailing list