My 2 cents on TDD

I was wondering if I should post or not my thoughts around TDD. TDD always was and I think it will always be a polemic subject. From time to time someone published something and the never-ending-debating come up again.

Uncle Bob post "TDD Harms Architecture". I do agree with most of Uncle Bob points, however, I do want make clear some of my own opinion on the in this matter.

Testable Code

Code must be testable otherwise, it becomes an issue not only for maintenance but ultimately as we all know tech debt could be a cause of availability issues. If you can't test your code you can't know if is correct and you can't easily refactor it. So having a testable code is essential for productivity and code scalability(having more people touching the same piece of code).

TDD helps to make your code testable, however, you don't actually need Test First or TDD discipline to make tests or to make your code testable. Junior Engineers might benefit a lot from TDD however, as a Senior engineer this should be in your DNA make safe code with tests and testable code of course.

Architecture and Design

IMHO TDD effect on Design or Architecture is minimum and I do agree with Uncle bob when he says it's you that make code Design and Good an architecture, not TDD.  TDD is more like a mindset rather. In the past, I saw several times people argue that TDD makes you do better design and I never agree with that.

Design and Architecture it's about thinking and knowledge on patterns and algorithms, requires trade-off thinkings and TDD does not help you in any of this things. Not every POJO needs to be tested and making tests to code won't guarantee your design choices are correct neither if they scale.


Frameworks are a good and a bad thing at the same time. Because the FRAME your mind to think in a very specific way which is good and bad at same time. Software development frameworks that force you to always code in the same direction(which is pretty much all framework does) always can and will lead you to pitfalls. That's why again, you have to think.

TDD does not think for you. So TDD can't really help you on design and architecture.

Diego Pacheco

Popular posts from this blog

Kafka Streams with Java 15

Rust and Java Interoperability

HMAC in Java