I find it useful to have assert
statements in my code. It has several benefits:
- Self documents code expectations
- Establishes boundary checks between component
- Helps to pinpoint problems by failing fast, especially when you just started dealing with a new library
- Here is a good summary on using assertions.
In a dream world all this can be addressed by sophisticated type system but we all know it’s not going to happen any time soon.