¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Which comes first: design skill or TDD?


 

For me, learning TDD the hard way (by doing it a lot, badly, with little guidance beyond the books and dev blogs available in the early oughts) led to a massive improvement in my software design skill.
More than that, it changed the way I think about software design so that even when not doing TDD for (reasons), I write "testable" code, because?"testable" just means "simple".

Big caveat: I was about 10 years into my career when I first tried something-called-TDD, and it was maybe 5 more years before I felt comfortable enough to mentor others.
It's possible that this improvement was due to other reasons, and just happened to coincide with TDD adoption. But I don't think so.

I've also observed a similar growth in folks I've mentored, of varying experience levels, in the 15 or so years since I first felt comfortable with TDD.
Again though, It's really hard to definitively attribute this to TDD.
Usually TDD is practiced by more experienced?programmers, so an environment of TDD-ers is probably generally good at mentorship.
It also tends to correlate with other collaborative XP-descended working styles, which probably has a positive effect on such things.

Learning TDD by just doing it, even badly, really taught me about its traps -- overmocking, falling back to end-to-end testing in a "hard-to-test" system, focusing too much on trying to simulate human behavior, just plain writing too many tests, and a whole lot more.
Recognizing those traps is really useful when guiding less experienced folks on their journeys.

If I think back on it, it occurs to me that when I was learning TDD, I followed red/green/refactor extremely closely (although at first, like most, I didn't focus on the refactor step enough).
Now, I really don't hew to that cycle very often. I don't even know if I can claim to do TDD regularly at present, by common definition.

Dave

On Tue, Jul 4, 2023 at 11:36?AM Mauricio Aniche <mauricioaniche@...> wrote:
Hi, JB! Thanks for starting such an interesting thread.

I'm a strong believer in a slight variation of what you said. If you
want to get the best out of TDD, you need to deeply know about
software design.

IMHO, TDD doesn't magically guide you to good design. Sure, in
information systems, where many of the design decisions are related to
object creation and encapsulation, TDD is a great way to quickly
validate if you are going in a good direction. Maybe in such cases you
don't really need a deep background in OOD to listen to your tests
saying that your class is hard to be instantiated or that you aren't
encapsulating things properly, and so, TDD pays off handsomely even to
those that still haven't mastered OOD.

However, if you are building highly flexible applications / libraries
/ frameworks, I hardly think that TDD is enough. As an example of a
library I was diving into the code today: the extensibility model of
JUnit 5. It was clearly created by someone who profoundly understands
object-oriented design principles and how to build elegant and
flexible APIs. A non-expert in OOD, even with TDD, wouldn't be able to
do it no matter how perfect their TDD sessions were.

Cheers,

--
Maur¨ªcio Aniche
Author of Effective Software Testing: A Developer's Guide


On Tue, Jul 4, 2023 at 6:55?PM Russell Gold <russ@...> wrote:
>
> Refactoring to simplify code leads to cleaner designs. If nothing else, you should get a better feel for what makes a clean design. On the other hand, if by ¡°design¡± you¡¯re thinking mainly systems-level, I don¡¯t really see TDD as helping.
>
>
>
>
> On Jul 4, 2023, at 10:05 AM, Kevin Rutherford <kevin@...> wrote:
>
> JB,
> I'm quite surprised by your second claim, that "One can learn design
> skill by practising TDD".
> Can you support that?
>
> K
>
> On Tue, Jul 4, 2023 at 2:43?PM J. B. Rainsberger <me@...> wrote:
>
>
> I am surprised to encounter so many people who claim something like this:
>
> "You must understand how to design before you can practise TDD well."
>
> I say the following in response:
>
> - Practising TDD "poorly" still helps many programmers
> - One can learn design skill by practising TDD, and I consider this a kind of pracitisng TDD "well"
> - Your claim, framed that way, needlessly scares programmers away from TDD who need it
>
> Practising TDD well and improving design skill forms an amplifying feedback loop, don't you think?
> --
> J. B. (Joe) Rainsberger :: tdd.training :: ::
>
>
> Replies from this account routinely take a few days, which allows me to reply thoughtfully. I reply more quickly to messages that clearly require answers urgently. If you need something from me and are on a deadline, then let me know how soon you need a reply so that I can better help you to get what you need. Thank you for your consideration.
>
> --
> J. B. (Joe) Rainsberger :: :: ::
> Teaching evolutionary design and TDD since 2002
>
>
> -----------------
> Author, HttpUnit <> and SimpleStub <>
> Now blogging at <>
>
> Have you listened to Edict Zero <>? If not, you don¡¯t know what you¡¯re missing!
>
>





Join [email protected] to automatically receive all group messages.