3 ms·
I find that doing TDD makes it much easier to get in the zone; more importantly, it helps to get back into the zone if I get off track. I typically stub out a
by QuercusMax 9y ago
I find that doing TDD makes it much easier to get in the zone; more importantly, it helps to get back into the zone if I get off track.
I typically stub out a bunch of tests (just empty methods named based on what I plan to test), then go one by one and fill in the tests and write the implementations.
In the codebase I work in, we use a lot of mocks / fakes, so I typically write my tests "in reverse" - first the verification of results, then the mock / fake expectations for what methods should have been called. Then I'll write the actual implementation, and then fill in the mock inputs.
This way, if I get interrupted, it's very easy to transition back into what I was working on, as I make sure to always leave a breadcrumb trail for the next piece (when I run my test, the failure will give me a hint as to the next step to take). And since I have a bunch of stubbed out test methods, once one bit is finished, I can move onto the next one and repeat the process.
- askafriend 9y agoThe style of work you described sounds like torture to me. I don't know why the idea of TDD sounds so terrible to me but it does.
- dozzie 9y agoBecause it sounds like "start with tests, design and plan never". Too often tests-first is a substitute for a thought-out architecture and data flow.
- QuercusMax 9y agoThat's certainly true; but when you've done your homework, it can be a really great experience. For example: the past 3 weeks I've been pounding out tons of code in a TDD fashion. But prior to that: * I spent a week writing up a detailed design document and getting feedback from teammates and stakeholders. * Another week refactoring (TRULY refactoring; no changes to functionality) the existing implementation so I can reuse the existing work in my new implementation.