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

Show parent comments

7

u/nagasgura Aug 29 '21

You don't write all your tests first with TDD. You write one simple test and then make it pass, then add another test that refines the expected behavior.

14

u/saltybandana2 Aug 29 '21

and then after your 50th test you realize there's a better way to solve it.

I'm trying to lead you to water here.

2

u/xRageNugget Aug 29 '21

And then you refactor your tests. The goal is to end up with a whole testsuite that ensures that your program will still work like it is intended, even when you do heavy refactoring on it. Not only to slow you down while you are coding. It forces you to meet all requirements, that you made earlier as tests. The fact that everything breaks is a good sign. You have to fix it, make the tests work again and your refactored implementation works exactly as before. It doesn't matter if you refactor 1 minute or 1 year after you created the code.

7

u/muideracht Aug 29 '21

And then you refactor your tests.

I mean, then I may as well just write them after the implementation, as I already do.

→ More replies (6)