[lug] can't make this stuff up, folks... My 2 lines of code, errr, I mean, my 2 cents....

Bear Giles bgiles at coyotesong.com
Tue Oct 20 13:19:57 MDT 2009


On Tue, Oct 20, 2009 at 12:37 PM, Rob Nagler <nagler at bivio.biz> wrote:

> I find that it takes much longer to create the test data and structure
> than to write the code.  I've never timed it, though.  If I'm just
> hacking something together ("spike" in XP parlance), I spend almost no
> time on testing.  If I'm working on importing accounting from OFX
> servers, test data are extremely important.
>
> So the question I ask myself: What's the value to the customer of what
> I produced today, and have I mitigated the known and unknown risks?
> That's a very tough standard, but I see no point in asking any other.
> Do you?
>
>
The Sun PetStore application were the canonical example of how NOT to do
it.  A lot of people got misled by it.  it's somewhat common for new
frameworks to show how to do the same thing using their framework and that
10x reduction is fairly common.

I've found it useful to replace "unit test" with "regression test" in my
head, at least for the first round.  The tests can be shallow.  They just
need to be deep enough to catch it if somebody making a change has an
unexpected side-effect.  We've caught a few newborn bugs that way since the
regression tests failed immediately.  It's easy to update the
unit/regression test but that gives a chance to consider what else the
change might affect.

The same argument applies to the web-tier unit/regression tests.  It's
cheaper and faster to do automatic regression tests with canoe or the like
than to train people to perform regression tests on every build.

You still need deep tests on critical code but as you implied you can focus
on the things where it really matters.

BTW, any other java developers out there should look at "findbugs" from
Univ. of Maryland.  You'll probably want to turn off some of the clutter
caused by your coding style but it routinely found bugs in our "clean"
code.  Definitely kept us humble.

(An example of code that it complains about is:

String s = "";
if (!p.isEmpty()) {
  s = p;
}

The problem is that the value 's' is changed before it's been used.  This
sounds like there's a problem - did we unintentionally overwrite a value
before we used it?  Did we make an unnecessary calculation?  On the other
hand a lot of people use this style as a way to emphasize that the value
will always be initialized.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20091020/f57e698a/attachment.html>


More information about the LUG mailing list