3 ms·
One of the most irritating things about this book that I found with that section was that the process was: 1. Write a test for function(5) == 20. 2. Make functi
by monksy 14y ago
One of the most irritating things about this book that I found with that section was that the process was:
1. Write a test for function(5) == 20.
2. Make function { return 20 }
Then it goes to the next input:
1. Write a test for function(4) == 16
2. Make function { return parm * 4 }
This gets annoying when you know the problem is to make a function multiply by 4.
- ollysb 14y agoI seem to recall that he talks about step size. The technique you're referring to is called triangulation, where you use sets of inputs/outputs to progressively generalize the implementation. It's good to know how to work at this small "step size" for those occasions that you're working on something complex or simply don't have much of an idea about how to implement something. If you're coding a familiar problem then you can increase the "step size" and not take all the baby steps i.e. for the example you mention you would probably just use a single input/output set and code the final implementation immediately. The key is understanding that you can start with a larger "step size" and then backtrack and increase the granularity of your steps if you find things are getting a bit hairy...