Follow

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

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!