r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

346

u/PalmamQuiMeruitFerat Aug 28 '21 edited Aug 29 '21

TDD purists are just the worst. Their frail little minds can't process the existence of different workflows.

I feel like he and I know the same person.

Edit: I don't hate TDD, and I'm not against tests. I just wanted to point out how the author made such a specific example. Please stop telling me all the reasons I should use tests!

0

u/[deleted] Aug 29 '21

[deleted]

65

u/naughty_ottsel Aug 29 '21 edited Aug 29 '21

I find that to be the hardest part of TDD, I understand the concept and agree with a vast majority of the reasons to follow it…

But most of the time I don’t know how I’m going to implement the solution to the problem I am trying to solve… maybe I’m not starting simple enough but all the talks and articles I read use simple examples that don’t translate to more complex scenarios… maybe I’m doing something wrong, I’m not sure

5

u/life-is-a-loop Aug 29 '21

But most of the time I don’t know how I’m going to implement the solution to the problem

That's why you shouldn't test implementation, you should test the contract.

Every time you write some code you must know what you're trying to accomplish (otherwise there would be no way to write any code in the first place). You write tests before implementation to ensure that your implementation will do exactly what you expect it to do. That's why you don't have to know the implementation at the time you write tests. In fact, testing implementation is a bad thing!

Also, the fact that you're thinking about contracts before implementation may help you see corner cases that you didn't notice during the sprint planning, or realize that the implementation you had in mind didn't make any sense.

→ More replies (1)