2 ms·
TDD always seemed like a impossible thing to a developer like me. The problem is something like this, the moment I face a programming task- If the task is a li
by kamaal 14y ago
TDD always seemed like a impossible thing to a developer like me.
The problem is something like this, the moment I face a programming task- If the task is a little complex I do some work on the notebook else I directly fire up the editor and write some code. Now unless I get some code/prototype up and running I can't proceed further. That is how my mind works.
I don't know how anyone can write tests about the idea/task for which they haven't written a line of code. I've found it impossible. For me, its always:
step 0. Basic version of Idea.
step 1. Write code.
step 2. Making it nice(optimize/document/clean up).
step 3. Make it run faster.
step 4. extend idea and repeat steps 1 to 4.
I'm jealous of all those people who can have a 'step -1' where they can write test cases 'for the code' they would end up with in 'step 4', even while they have a very blurry version of the idea.
To me this has always looked like premature optimization. Like putting the cart before the horse.
- nahname 14y agoMost people 'spike' an initial version to discover what they have to do. It is very hard to test drive something when you have no clue how it is going to work. Could you test drive the code for the very first controller action you ever wrote? No. But the second controller action should be easy to TDD.
- kamaal 14y agoSorry when I look at a problem, I think about the solution for the problem. And not testing the solution.
- nahname 14y agoI am not sure how they are mutually exclusive. You are going to test that your solution works. Switching from manual confirmation to automatic confirmation isn't so difficult. The real trick is figuring out your expectations before you write you code. Which makes sense when you think about it. When this code works, I will see the username show up in the view. Versus. assigns(:username).should == "expected" I realize this example is trivialized, but these are the usually examples people start with when they are learning how to start with tests instead of code.