Op 2006-01-06, Terry Hancock schreef
I don't think unit tests are that helpfull in this case.
Unit tests help you in finding out there is a bug, they
don't help that much in tracking down a bug.
I for some reason a person is reading over the difference
between sumLongName and someLongName and doesn't notice
the different spelling in his source a unit test won't
be of much help.
Well, if you are doing fairly frequent unit tests, then you
will have written a unit test to test the "someLongName"
method, and if you manage to type "sumLongName" in BOTH the
code and the unit test, then there must be some Freudian
reason you really did want to use "sumLongName". ;-)
It's a bit like the standard practice of making you type a
password twice. In fact, most of the common "bug avoidance"
methods in programming all come down to this -- you have to
type the same thing twice in two different places to get
the result.
C and C++ make you do declarations -- so you have
to mention the name before you can use it. You have to type
the variable names twice.
Interfaces define the "publically viewable" parts of a
class, then you have to actually create them in a separate
class definition. You have to type the methods twice.
In unit testing, you write the code, then write code to test
the code, which must correctly identify the methods in the
code. So you have to type 'everything' twice.
And so on.
The ideal of "don't repeat yourself" seems to get
nudged out by "repeat yourself exactly once" when it's
really important to get it right. ;-)
It's really just a fancy way to force you to proof-read your
own work carefully enough (which is tricky because you
tend to ignore stuff that's too repetitious).
Cheers,
Terry