In my experience, using a type system to do this requires much less effort and refactoring.
In my experience, using a type system to do this requires much less effort and refactoring.
Yes. TDD came from developers who worked in weak/dynamic typed languages.
It is mandatory to discover errors, that are otherwise discovered instantly for free by compilers in the stronger typed languages.
Strangely, the TDD folks never outline this point.
Unit tests can demonstrate that my code is correct; it can say nothing about how my code is used by others.
In contrast, a type system can extend those protections downstream.
(Yes, yes, unless you go way off the deep end of dependent types, you still need tests. But a powerful type system can systemically prevent a huge number of very common bugs.)
As for dependent types, I'm not sure that even then you would be able to ensure that, say, your cache is correctly invalidated.