4 ms·
Sounds to me like tests could have helped your code far more than any comments would have.
by kenbot 14y ago
Sounds to me like tests could have helped your code far more than any comments would have.
- dagw 14y agoSome stuff, especially stuff connected to performance or memory usage, is very tricky to write tests for. Doubly so if it is only a problem on certain hardware.
- kenbot 14y agoThat's certainly true. I'd argue though, that most code is in a position where good naming and tests provide sufficient clarity, without requiring free-text comments.
- dagw 14y agoTests can only tell you what some piece code is supposed to do, not why its doing it the way its doing. Why do you choose to define this particular constant to this particular value, why are you using that particular data structure, why are you rolling your own version of a certain function rather than using the one supplied in the library you are using, why are you using that seemingly round about way to get to that particular result? There are lots and lots of ways to write a function that passes a test, I want to know if there is a reason why you chose the approach you used.