Comment Re:Write the test first (Score 1) 321
I will give one (not exaustive) example of TDD giving better code:
Interface vs. Implementation
Writing a test to a non-existent module requires the definition of an interfaces for client code to call. The question foremost in my mind is "How ill this be used?". Writing the implementation first risks focusing on the implementation in favour of the interface. I start thinking, how do I make this work? In mature systems, callers often outweigh implementations by several orders of magnitude. So interfaces often matter more than implementations.
Geniuses who produce perfect interfaces as a consequence of their masterful implementations may not care. But I find it much easier to clean up a bad implementation 18 months later than fix 782 callers that fight with a clumsy interface.
Interface vs. Implementation
Writing a test to a non-existent module requires the definition of an interfaces for client code to call. The question foremost in my mind is "How ill this be used?". Writing the implementation first risks focusing on the implementation in favour of the interface. I start thinking, how do I make this work? In mature systems, callers often outweigh implementations by several orders of magnitude. So interfaces often matter more than implementations.
Geniuses who produce perfect interfaces as a consequence of their masterful implementations may not care. But I find it much easier to clean up a bad implementation 18 months later than fix 782 callers that fight with a clumsy interface.