10 Comments

Some good points, but I admit I don't agree with everything you said

I think this post may answer some of your points

https://blog.thecodewhisperer.com/permalink/tdd-for-those-who-dont-know-how-to-design-software

Expand full comment

I'm relieved I'm not the only one struggling with TDD :)

Expand full comment
Feb 6Liked by Bite Code!

Loved the article, there are a bunch of hot takes! ha

Expand full comment
Feb 4Liked by Bite Code!

Thank you for sharing your experience.

Expand full comment
Feb 4Liked by Bite Code!

Thank you for the article. I think there is even some literature about this, telling us that it's important to write tests before or after the corresponding code but that it doesn't matter which one around. Sadly I don't know the source since it's prime hearsay from a podcast.

"The tasks of programming are many, and some are very suitable for tastings, while others, are not."

Did you really mean tasting?

Maybe the junior programmers break room coffee? :-)

"I've met people for whom it works, a few exceptions, very good programmers, methodical, experimented."

Experimented? Were they experimented on or are they just experienced?

Best!

Expand full comment
author

Thanks, I''ll fix that.

Expand full comment
Feb 4·edited Feb 4

> TDD comes with another hidden assumption: it's that you know the solution to your problem.

I think this is one of the biggest misunderstandings about TDD. TDD does not imply that you need to write a test first for tasks that you don't yet understand. To address this issue, people came up with 'spiking' - it's when you, trying to figure out a problem, write a simple prototype without tests in order to understand the issue. Then, once you have all the answers, you return to TDD - rewriting your "dirty" solution.

Also I want to quote something from the internet:

```

In software development, sometimes we aren’t sure how to solve a problem. It may happen when you are using a new API, framework, or just because you never had a similar problem before. Using TDD in this scenario is hard. In order to write the test first, you need to be able to define the expectations, if you don’t know that, TDD is gonna be really challenging. In Agile Development there’s a technique for this situation called Spike. This term comes from Extreme Programming, where “A spike solution is a very simple program to explore potential solutions”. To implement a spike solution, you normally create a small program very quickly testing the problem in question. When you have the answers that you need, you go back and build it again, but this time using TDD.

```

Expand full comment
author

So, do as usual, and use tdd when you are really, really sure :)

Expand full comment

Not exactly, because in a spike, you typically write very dirty code, omitting details like performance, security, etc., in order to answer the questions you have quickly. After that, you discard your solution and write a new one using TDD, but now, with the answers you got from the spike, focusing on performance, code readability, security, etc.

"Usually," we try to write production code right away, simultaneously thinking about performance and readability and getting answers to our questions for a task that is unfamiliar to us.

Expand full comment
Feb 4Liked by Bite Code!

Great essay! Says everything I have thought about TDD, much more coherently, and says a lot more, besides. Thanks for the effort, and the voice of experience.

Expand full comment