4 ms·
Frankly good type systems displaced TDD for me. They do a better job getting at the goals of TDD than TDD does. Types in good systems (OCaml, Rust, Typescript,
by tel 6y ago
Frankly good type systems displaced TDD for me. They do a better job getting at the goals of TDD than TDD does. Types in good systems (OCaml, Rust, Typescript, Scala, Haskell, others) are 100% laser focused on depicting good public interfaces and laying out their behavior.
Sometimes you need a test or two to really nail down this behavior. That'll give you a TDD-like flair. But it's not the same because you've already invested so much productive thinking time into the interface driven purely by the types. At that point, TDD is good hygiene, but not a transformative practice.
- terrortrain 6y agoFor js->ts, this is right on the money. When I started unit tests way back when, half the tests were just checking what happens if you give it strange arguments.TS now does that job for me. Another thing that has cut down on the number of tests is switching to pure functions for most things. And trying to isolate side effects as much as possible, so you really don't need to write to many tests around it. If the function only has one or two lines, typically types are enough to catch potential issues.
- mattmanser 6y agoIt's one of the things that really frustrates me with the ASP.net team. They're obsessed with unit testing, have made really stupid decisions that means tons of stuff now gets injected instead of just passed, all in the name of unit testing. But C# is a typed language and generally doesn't need reams of unit tests, so all it does is make the code unnecessarily complicated. My big bugbear was when they idiotically made the config injected, of all the things that should be super simple to use, and definitely not injected, it's config. It only changes between environments.
- jacques_chester 6y ago> Frankly good type systems displaced TDD for me. They do a better job getting at the goals of TDD than TDD does. I think it's a false dichotomy. Where you have types, use types. Where you don't, use tests. Either way, get a tool to guide you to the answer and then check the invariant during future changes. In fact TDD made me more aware of and appreciative of types. Writing types-by-hand is very tedious and wasteful.
- terrortrain 6y agoWriting types by hand is not any less wasteful than writing documentation.
- andrewedstrom 6y agoThere is a great talk by Gary Bernhardt exploring this exact view. It shows how types and and tests actually do not solve the same problems and are not interchangeable. https://www.destroyallsoftware.com/talks/ideology https://www.destroyallsoftware.com/talks/ideology
- blandflakes 6y agoI didn't RTFA from Gary Bernhardt, but this has been my experience. I love types, but it's not like good types replace good tests. They just eliminate some states from the search space.