How to assert for fun and profit (2022)

In this hastily put together guide, the author discusses the misunderstood concept of assertions in programming. They recount an experience with Java where assertions failed to function properly, leading to confusion. The author clarifies that assertions should be used to specify conditions that must always be true at a certain point in code execution. They emphasize that assertions should be pure and not impact the program’s state. The author also highlights the importance of self-explanatory assertions and warns against relying solely on assertions for input data verification. They explain the pronunciation of assert and provide insights on when to use assertions. The author concludes that assertions are not only for testing purposes and suggests using a language with a type system that prevents invalid states.

https://www.aarsen.me/posts/2022-11-18-i-assert-thee.html

To top