1 Apr 2006 19:07
Re: Re: TDD by Intention - Refactored
<yahoogroups <at> jhrothjr.com>
2006-04-01 17:07:19 GMT
2006-04-01 17:07:19 GMT
From: "Jeffrey Fredrick"
<jeffrey.fredrick.at.gmail.com <at> yahoogroups.at.jhrothjr.com>
To: "testdrivendevelopment <at> yahoogroups.com"
<testdrivendevelopment.at.yahoogroups.com <at> yahoogroups.at.jhrothjr.com>
Sent: Saturday, April 01, 2006 8:47 AM
Subject: Re: [TDD] Re: TDD by Intention - Refactored
I'm snipping most of this because I really want to address
one point.
> After thinking about this problem for awhile I'm going to make up a
> number and see how y'all react: 30% of unfixed bugs currently
> existing AND manifesting in production code (perhaps as an odd crash
> now and again) are because someone adds a null to a collection and the
> effect of that happen far downstream of where the bug occured.
One of the things about OO is that I don't think it buys
you very much for toy problems. It introduces mechanism, and there's
always a cost to mechanism. Procedural code is going to be smaller
for toy problems, and possibly easier to understand. The real trouble
is that it doesn't scale very well.
The mechanism becomes useful for larger problems, where the
intellectual effort required to understand the system is aided by
having standard solutions to recurring motifs.
The only way the problem above could occur is if the collection
is not encapsulated in its own object, which manages access
and checks that items added do not violate the invariants.
This will catch the caller who tries to add a null to the
collection. Right away. Exactly where it occurs.
The solution is therefore fairly simple: if you get that kind of
a null pointer exception, encapsulate the collection, put in
the appropriate checking, and look at where it blows up.
It may seem like a lot of work to change all the calls to
the bare collection, etc. It is. However, it's work that's
going to pay off many times in the future.
There are a lot of shortcuts we habitually use. They
work, but they add to the intellectual effort required
to manage the program.
John Roth
> Jtf
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/testdrivendevelopment/
<*> To unsubscribe from this group, send an email to:
testdrivendevelopment-unsubscribe <at> yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
RSS Feed