On 17/06/2015 22:33, sohcahto...@gmail.com wrote:
On Wednesday, June 17, 2015 at 1:39:31 PM UTC-7, Marko Rauhamaa wrote:
Ned Batchelder <n...@nedbatchelder.com>:

TDD is about writing tests as a way to design the best system, and
putting testing at the center of your development workflow. It works
great with Python even without interfaces.

I wonder how great it really is. Testing is important, that's for sure,
but to make it a dogmatic starting point of development is not that
convincing.

The way it was explained to me was that in TDD you actually don't write
code to any requirements or design: you simply do the least to pass the
tests. Thus, say you need to write a program that inputs a string and
outputs the same string surrounded by parentheses (the requirement), the
starting point might be this test case:

    - run the program
    - give it the word "hello" as input
    - check that the program prints out "(hello)"

The right TDD thing would be to satisfy the test with this program:

    input()
    print("(hello)")

That *ought* to be the first version of the program until further test
cases are added that invalidate it.


Another interesting ism I have read about is the idea that the starting
point of any software project should be the user manual. The developers
should then go and build the product that fits the manual.


Marko

I had a Java class where we had to learn TDD, and that's the way TDD was taught 
to us, and I hated it.  We watched a video of this guy explaining TDD with a 
hat that was red on the front and green on the back.  It involved writing a 
simple failing unit test, then write code to fix it, then refactor the tests 
and/or code.

As an in-class exercise, we had to write an implementation of Conway's Game of Life.  I 
threw TDD out the window and just wrote the damn program in under 15 minutes, then 
another 10 minutes to write unit tests that tested every possible code branch and several 
invalid inputs.  Meanwhile, the people doing TDD the "right" way didn't even 
have a complete program after over an hour.

The brand of TTD we were taught would end up multiplying development time by at 
least a factor of 3, and by the time you were done, at least 75% of the tests 
you had written will have been removed due to rampant refactoring.

IMO, that kind of TTD is an utter waste of time.


Couldn't agree with you more. To once again quote my favourite part of the Zen of Python, "practicality beats purity".

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to