What is KZAsserts?

There are many ways in which we can improve quality of our code-base, Assertions are one of them. Yet very few people actually use asserts, why is that?

An assert is used to make certain that a specific condition is true, because our apps don’t exist in a vacuum and we often work with other API’s (or our own), we need to make sure our assumptions about it are actually valid or we might have really weird bugs.

If our assumption is wrong, assert will crash on the line that checks that condition thus allowing us to find bugs in our code very quickly.

This is great concept, crash early and crash often, it makes it easy to have clean and bug free code.

On the other hand Release build should avoid crashing whenever possible, unless you like 1-star rating?

Because of that normal assertions are not enough, you need to make sure your code handles errors even in release builds, if you just strip assertions from release you are still going to crash if your assumption was wrong (eg. after striping asserts you’ll have code that mismatches types etc.)!