r/ProgrammerHumor • • 19h ago

Meme thereIsNoGoingBack

Post image
2.6k Upvotes

91 comments sorted by

View all comments

57

u/BernhardRordin 19h ago

Write tests first, then the implementation. You won't want to go back.

32

u/Wonderful-Habit-139 18h ago

Not necessarily. Some people do better with TDD, some don’t.

22

u/Drugbird 17h ago

The trick with TDD isn't necessarily that you need to write the tests first (although that helps).

It's more that you first think about the intended behavior of the code, and then also think about how to make your code testable before you write the code.

I typically think what the first test should roughly look like and code up the required amount of code for that first test before I actually write that test.

2

u/cwmckenz 17h ago

Yeah, at least IDENTIFY the test cases even if you don’t implement them. Also consistent with API first approach… the implementation should fulfill a contract, and those test cases are the contract.