> Or even: 1. Test 2. Implement
IMO, this last popular approach gets things completely backwards. It assumes there is no need to think about the problem before hand
I think you misunderstand this approach.
The point of writing the tests is to think about the desired behaviour of the system/module you are implementing, before your mind gets lost in all the complexities which necessarily happens during the implementation.
When you write code, and hit a wall, it’s super easy to get hyper-focused on solving that one problem, and while doing so: lose the big picture.
Writing tests first can be a way to avoid this, by thinking of the tests as a specification you think you should adhere to later, without having to worry about how you get there.
For some problems, this works really well. For others, it might not. Just don’t dismiss the idea completely :)
I'm being a little rhetorically over the top. Of course, sometimes it's what you have to do.
In fact, right now I'm doing exactly Test/Implement because I don't know how else to solve the problem. But this is a last resort. Only because the first few attempts failed and I must solve this problem have I resorted to grinding out individual cases. The issue is that I have my back against the wall and have to solve a problem I don't understand. But as I progress, eventually I will understand the problem, and then my many cases are going to get dramatically simplified or even rewritten.
But all the tests I've created along the way will stay...
I think you misunderstand this approach.
The point of writing the tests is to think about the desired behaviour of the system/module you are implementing, before your mind gets lost in all the complexities which necessarily happens during the implementation.
When you write code, and hit a wall, it’s super easy to get hyper-focused on solving that one problem, and while doing so: lose the big picture.
Writing tests first can be a way to avoid this, by thinking of the tests as a specification you think you should adhere to later, without having to worry about how you get there.
For some problems, this works really well. For others, it might not. Just don’t dismiss the idea completely :)