4 ms·
According to TDD writing inside-out is one of the points it tries to combat. The point of using TDD to write interfaces is that you first write the code you wi
by zumda 15y ago
According to TDD writing inside-out is one of the points it tries to combat.
The point of using TDD to write interfaces is that you first write the code you wish you had, and then implement it. The other way around you could end up with code that is optimized for the code inside the module, and not optimized for using it.
Of course now you have to rewrite your tests and your code when changing an API, but at least you know that no other part of your application got broken by the new API.
I personally like the TDD approach to write interfaces, since then I won't take shortcuts just because it is easier to do in the specific module that I'm programming/extending. It will actually produce code that can be used easily from the outside and removes a lot of dependencies in the process.