4 ms·
You can't always, though. I described a situation where TDD really, really, really wouldn't have worked. The whole structure needed to be developed, or at leas
by SomeCallMeTim 4y ago
You can't always, though.
I described a situation where TDD really, really, really wouldn't have worked. The whole structure needed to be developed, or at least 80% of it, before it would have made sense to write any tests--and the actual TDD philosophy would be to write "one small test" and only write exactly as much code as required to satisfy the test.
The sane approach was to create the entire structure based on the design, and then test it after it was complete as an entire system. Some of the micro-functionality that TDD would have had you test would have become technical debt as a change-detector later when the client changed their specific requirements.
As I said above, there is no evolutionary path from tiny pieces to the full structure, and TDD requires that you follow such an evolutionary path. If you're writing a bunch of tests and then creating a nontrivial amount of code, then you're following test-first, but not really following TDD. And I question even how valuable that is when you don't necessarily understand what would need to be tested before you've finished implementing the system.
- ivan_gammel 4y agoI disagree with you here. TDD does require evolutionary path for the entire system, but the minimum unit is a feature that is expected to be fully specified and implemented to pass the first test. You cannot evolve a data structure or an algorithm with TDD, because TDD by original definition allows only refactoring, not re-engineering (I.e. if your feature is addition, writing „return 4“ to pass test2plus2 isn’t meaningful TDD). So in your case properly applied TDD would require fully implemented structure or at least an atomic part of it within the known design to pass the first test (e.g. testing Feistel round function in an encryption algorithm is ok, but you will know the design of the entire algorithm from the start).