[Please do not mail me a copy of your followup]
Wouter van Ooijen <
wou...@voti.nl> spake the secret code
<56c4c5ef$0$4200$
e4fe...@newszilla.xs4all.nl> thusly:
>(Of course when you define 'doing [TDD] well' as 'when it works' *any*
>methodology works well....)
As someone that has introduced TDD to every team I've worked on for
the past 10 years, I can pretty quickly tell the difference between
someone doing it right and someone doing it wrong.
What is "doing it wrong"? Dr. Evil gives a nice example:
<
http://cdn.meme.am/instances/54444468.jpg>
In general, the people I see struggling the most with TDD are the same
ones that struggle to make small methods and small classes. They
routinely violate SRP and the other SOLID OO design principles.
<
https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)>
When practicing TDD, if your tests start getting complicated, that is
a signal being given to you by your code. The tests are telling you
that your implementation/design is too complex. Someone who is used
to writing long complicated methods and isn't used to following SRP
chafes against TDD because it is actively making it hard for them to
do what they are used to doing.
Psychologically this puts you in a bind. You want to embrace SRP and
other SOLID design principles, because everyone knows they are
intrinsicly "good". Historically your code doesn't embody those
principles, but this hasn't been explicitly brought to your attention
or you've rationalized away your violations of those design principles
through utility or necessity. TDD is putting your feet to the fire
and forcing you to adhere to those principles in practice and not just
in theory. Doing this means changing the way you've been writing
code. It's uncomfortable. It's painful to write code in the familiar
way with TDD because your tests get really complicated and painful to
write.
I've seen people work their way out of this psychological bind in two
ways:
1. Change your coding habits to adhere to the SOLID principles more
directly and embrace TDD's ability to keep you honest.
2. Discard TDD and complain about how it makes you write really
complicated tests and wastes time.
The people I've seen choosing option 2 keep writing long methods and
big classes and keep producing code that is very difficult, and
sometimes impossible, for their teammates to understand, maintain and
enhance. Their productivity remains unchanged.
The people I've seen choosing option 1 are initially going slower
because they are retraining their mental programming muscles to
operate in a different fashion. After they build up their TDD
muscles, they end up moving faster than those that chose option 2
because they are able to produce code at the same quality faster
or better quality in the same time as those choosing option 2. Here
"time" has to be measured across design, develop, test and ship
lifecycle of a product/release and not just the "develop" part. The
empirical studies on TDD being introduced to teams show similar
results to what I've witnessed in my personal experience.
Don't like TDD? Fine, don't use it. I would suggest that you try it
for real before you decide that it has no merit. I've seen enough
people doing it wrong to know that it is difficult for some people to
understand what TDD is really asking them to do. It's less about the
physical tests than most people think.
Trying to convince me that TDD is a waste of time? You'll have to
show me how to achieve the same or better results with something else.
I've spent more years doing non-TDD development than I have spent
doing TDD. I have plenty of experience doing things both ways. My
experience has shown me and my immediately coworkers that TDD allows
us to ship better code with the same effort.
Obligatory comment for wood brain dead 77:
shitty shit, shit shit shit.