Correct code/unit testing (was Re: Efficient python programming...)

Peter Hansen peter at engcorp.com
Tue Jun 11 00:12:55 EDT 2002


Kragen Sitaker wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> > Have you never spent a large amount of time carefully
> > designing and coding a wonder little program, and checked it over
> > very carefully, even with a peer, and later found a bug in it?
> 
> Of course!  People are fallible, it's much easier to do a bad code
> review than a good one.

I have to confess I have never seen a successful code review, nor
an environment in which they were used regularly and which had a
high level of code quality.  Clearly as a result I'm fairly biased
against them -- I should keep a more open mind on the issue perhaps.

I'm swayed also by the thought that programmers generally rebel
against them, and that therefore they are likely not the best
approach in most shops.  Learning XP has taught me that a process
which works in a way programmers find natural is much more likely
to succeed than one which goes against the grain.

> I think now we have each committed the same arrogant gaffe in this
> discussion: "It is only possible to disagree with me if you do not
> know what I am talking about."  I was wrong, and so are you.

Point taken; my apologies.  (I'm about to go on vacation to NYC for
the rest of the week, so if I suddenly go silent, it's not personal. :)

> I think inspection can find bugs that are very difficult to find by
> testing, and vice versa.  That is the reason for my second statement;
> a balance of careful reasoning and testing can produce better code
> than the same amount of time spent on either alone.

For code not written test first, I would strongly concur.  For code
written test first, I believe the resulting modularity and cohesion
in the code mostly negates the value of inspection.  Again, other
practices from XP are probably polluting my mind against such things --
in this case pair programming.  Assuming the formal 'inspection'
advocated by some heavy-weight processes, I think it's of little
use on code pair-programmed.  (We could also be more general and
just say that pair programming is on par with inspection and that
either is effective in an appropriate context.)

Cheers,
-Peter



More information about the Python-list mailing list