r/SoftwareEngineering • • Mar 10 '25

TDD on Trial: Does Test-Driven Development Really Work?

I've been exploring Test-Driven Development (TDD) and its practical impact for quite some time, especially in challenging domains such as 3D software or game development. One thing I've noticed is the significant lack of clear, real-world examples demonstrating TDD’s effectiveness in these fields.

Apart from the well-documented experiences shared by the developers of Sea of Thieves, it's difficult to find detailed industry examples showcasing successful TDD practices (please share if you know more well documented cases!).

On the contrary, influential developers and content creators often openly question or criticize TDD, shaping perceptions—particularly among new developers.

Having personally experimented with TDD and observed substantial benefits, I'm curious about the community's experiences:

  • Have you successfully applied TDD in complex areas like game development or 3D software?
  • How do you view or respond to the common criticisms of TDD voiced by prominent figures?

I'm currently working on a humorous, Phoenix Wright-inspired parody addressing popular misconceptions about TDD, where the different popular criticism are brought to trial. Your input on common misconceptions, critiques, and arguments against TDD would be extremely valuable to me!

Thanks for sharing your insights!

45 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/RedditMapz Mar 10 '25

To be honest it's a bit abstract, you can sort of break things down to the point you basically have single method classes if you push the idea to the extreme.

I think there is an art to software architecture. And it is just intuition that leads me to break classes into smaller components when I feel they are too big. There are rules I sort of follow as guidelines to consider breaking down code further:

  • A lot of nesting levels if-if-if-switch-for-if. I challenge myself to keep nesting of methods at 3. Can't always do it, but I try.
  • If an if code block needs a multi-line comment to explain what it does, it probably should be its own method with a descriptive name.
  • Long methods (say over 100 lines) probably do too much.
  • Once you do the above you end up with many methods focused on single units, maybe modifying a specific subset of member variables. And there it is, you successfully identified a smaller unit of code.

I'll you give an example. In C++ a lot of people write switch-case blocks in eternally long methods. It may have started as 2 case statements with 20-40 lines each. But over time that grows to 7-10 cases and hundreds of lines of code each with their multi line comment because they can do vastly different things. Well why not write a method for every case? Heck maybe that can be its own class that just handles those cases.

Again, it is not always that clear-cut or practical so it is very discretionary.

1

u/flavius-as Mar 10 '25

I see. What are your thoughts on this?

https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html

I think it's missing things akin to what you indicate, but I also think it's a good starting point for a mental framework around SRP - or how I call it: Stakeholder responsability principle.