What did Joe Armstrong refer to by "there are more advanced techniques" for unit testing

Viewed 78

What did Joe Armstrong refer to by "you shouldn't write test cases at all, there are more advanced techniques you can use than silly old test cases" ?

What are those more advanced techniques?

source: A Guide for the Perplexed

Additionally, he even suggests to not reuse code but to rewrite it. That goes against everything my school has taught me. So I'm wondering what is the reasoning behind this statement.

1 Answers

For the test cases: there’s a tendency for people who do functional programming to despise unit tests. Rich Hickey has a quote where he compares using unit tests to a car relying on bouncing off the guard rails to stay on the road. And he has a point, OO enterprisey code is so complicated and messy that’s pretty much what we do. The theory is, If you are doing FP right, you should be writing mostly small pure functions where it is self evident what they do. Testing at a unit test level doesn’t add much in that case.

(I can't say for certain but I don't know of anything to make me think Armstrong had a particularly strong focus on proving correctness of programs. Erlang doesn't have compile-time typechecking, which would seem to me like it would make proving correctness harder.)

For rewrite-not-reuse, I think the idea is, the value isn’t in the software, it’s in your understanding. If you reuse a lot you may find yourself cobbling together pieces each of which was your first try at figuring something out. And whenever we build something the first time, we don’t know what we’re doing and if we’re lucky it may mostly work, but it is pretty much crap. Rewriting gives opportunities for making connections and learning, it may be better to revisit the problems in a new light and have a chance to create something cleaner and better.

Related