How to actually write a program?

Dan Sommers me at privacy.net
Tue Sep 7 04:29:54 CEST 2004


On Mon, 06 Sep 2004 18:58:12 -0400,
Peter Hansen <peter at engcorp.com> wrote:

> Max M wrote:
>> Jp Calderone wrote:
>>> Close the file.  Open test_mykewlprogram.py and begin writing unit
>>> tests.
>> I completely agree in the value of test driven development, but for
>> someone writing a first program I completely disagree!
>> He will have to fight both programming in itself, and the test driven
>> development process.

> I would have thought that the TDD process was *how* one would "fight
> programming".  Do you have a better way?  All the approaches I've
> seen in the past were much, much more difficult and less assured
> of useful results in a reasonable time.

> (Also, as a new programmer, he is unlikely to have to "fight"
> TDD, since he doesn't have other approaches to try to unlearn.
> I assume unlearning old habits is what you were thinking about,
> because TDD itself is so simple that it's not at all hard to
> actually follow the process.)

Also as a new programmer, the OP is as unlikely to know how to write a
test, nor how to write a test that fails, nor how to write the code that
causes the test to pass.

Tests *are* programs.  My experience writing tests (in non-TDD
environments) is that the tests are often more "interesting" (as in "may
you live in interesting times") than the programs themselves.

>> Dont Repeat Yourself
>> ====================
>> If you have written a similar piece of code 3 times, you should
>> refactor it into a function.

> How does he get any code at all, when he doesn't know how
> to start?  You can't refactor what doesn't exist.

How can he write a test, when he doesn't know how to start to write a
program?

TDD assumes that programmers can write programs.

> -Peter

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
Never play leapfrog with a unicorn.



More information about the Python-list mailing list