Hi,
I'm wondering why the "assert" keyword is so underused in Java? I've almost never seen them used, but I think they're a great idea. I certainly much prefer the brevity of:
assert (param != null : "Param cannot be null");
to the verbosity of:
if (param == null) {
throw new IllegalArgumentException("Param cannot be null");
}
My suspicion is that they're underused because
- They arrived relatively late (Java 1.4), by which time many people had already established their Java programming style/habit
- They are turned off at runtime by default, WHY OH WHY??
Cheers, Don