I'm not convinced that it ever makes sense to use assert checks in our code.

In the case of test code, it seems to me that a JUnit assertion makes
more sense, as it is unconditionally checked.

In main code, does it make sense to use a check that is not guaranteed to run?
I would expect to see an IllegalStateException instead if the check fails.

However, if an assert IS needed, in most cases it needs a message to
ensure any failures contain sufficient information to determine the
cause of the failure.

For example:

assert length >= 10; // bad: what is the value of length?

assert length >= 10 : "Length: " + length; // good: show unexpected value

assert isEmpty; // does not need a message

Sebb

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to