Java assertions: Dos and Don'ts
I'm repeatedly confounded by misuse of assertions.
Do check the contract of your method and the validity of operations with assertions, even and especially when obvious.
Don't check things that might actually go wrong in production with assertions. They should be disabled at that point.
Do enable assertions in staging. That's where the integrity of the new code is tested.
Don't catch assertions. Let them kill the process.
Do use assertions as documentation.

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!