[Zope3-dev] Progress

Casey Duncan c.duncan@nlada.org
Mon, 4 Mar 2002 09:50:08 -0500


On Monday 04 March 2002 09:06 am, Martijn Faassen allegedly wrote:
> Chris Withers wrote:
> [snip a lot of stuff about test first, XP stuff, etc]
>
> A general comment. I agree with Stephan that sometimes writing tests
> first isn't the route *my* brain can handle; it indeeds requires a good
> understanding of the problem domain, and sometimes the best way for me
> to gain this understanding is to experiment or write a prototype; i.e.
> write code before tests. One can have a whole religious debate about
> extreme programming ideology, but we should be pragmatists first. And we
> should realize not everyone's brain works in the same way, so we're
> not all going to approach problems the same way. Some people are more
> up-front design, some people are more hands-on.

In theory test should always be written first. In practice, I'll be happy if 
tests are there that pass when the code is checked in or merged. The latter 
does introduce the problem of testing against code rather than concept.

You should never write tests against code, because then you are favoring it 
and probably not exercising it as well as you should be. So, if you must 
experiment and prototype, fine. But once you understand the code well enough, 
write some test to assert your understanding. I would suggest doing this as 
you go along with prototyping. If these test fail, either your understanding 
was incorrect or the code is incorrect. At least you then have something to 
go on.

We all do testing implicitly as we go along (I hope 8^), just make sure you 
write them down too. That is the key. Then if the tests pass and your 
understanding is still incorrect, somebody else can have some clue where the 
lapse was. Otherwise we have no idea what you were thinking, and no way to to 
know other than bludgening you on IRC 8^).

Writing tests is a pain in the ass, but it is *much* better than the 
alternative. Writing test for existing code is the worst though. You'll never 
do it unless someone forces you too or you are a masochist. So, writing the 
tests before or along with your code (the former is preferrable) is really 
the only practical way that tests get written consistently. Just human nature.

Ok, I'll shut up now.

/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/