Leveraging the type system to avoid mistakes

We all know we should write tests to make sure our system behaves as it is supposed to.

Surely tests are necessary to ensure correctness of our programs but they only depend on what the programmer is willing to test (or can think of testing).

What I mean is that there will always be gaps in the test coverage, like uncovered corner cases or improbable combinations of events, …

In Scala we have a powerful type system that we can use to help us avoid some mistakes.

Why would you bother writing a test to make sure a function handle some corner cases correctly when you can use the type system to make sure such cases won’t ever happen. Continue reading “Leveraging the type system to avoid mistakes”