Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Generalizing and naming is the purpose of functions. An add that only handles 4 and 5 need not exist; add(4,5) gets replaced with 9 and that's that. If I'm looking at a complex expression, it's easier to convince myself that it's right if it contains 9 than if it contains add(4,5). Why would I write an add(4,5) that fails and has to be repaired, if I can write a 9 that doesn't fail? It could only be because I'm anticipating a future generalization.

Oh, and can write a 9 that doesn't fail? That goes against TD; shouldn't I first break the lexical analyzer of my language so that the 9 constant goes red? Then repair things, so the 9 test goes green?

How can you call it TDD if you're relying on non-TDD pieces that work without being covered by tests that previously failed?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: