That probably will be a shortest post in this blog. Shortest coz I do not think that this subject deserve more. I should admit, more and more noise I can hear around this. I would say an any thread about a build system eventually diluted by Gradle. And you know what I think about this?
31 March 2013
15 March 2013
Part 2. "Какая гадость... Какая гадость эта ваша заливная рыба"
- You should avoid the assertion and use an IllegalArgumentException.
- Why?
- Coz assertion will be disabled in production. It changes behaviour of your application and may lead to confuse.
- (?!)
Actually reasoning could be different, from "misuse of feature" coz "it generates java.lang.AssertionError that indicates significant error, like java.lang.OutOfMemoryError" up to "it put application on unpredictable state". I was pointed out to google such matter. And I actually did this, after all...
I won't dive into the jungle of distorted perception of the world. So many people, so many opinions. I don't care, really. That is depend on how bad experience had been in past. What actually I should admit, if experience was overdosed by Spring, the reasoning could jump a really unexpected direction. That actually may not surprise, if you never saw your application in profiler, just a Spring configuration… How you may know what really your application are doing, right?
So often in past, hunting the idea what the heck burning the Joules on a CPU, I can see the ridiculous situation when simple action followed by tremendous effort in attempt to do so. Just from top of my head, an update the element of array of rates of the currency pair with an incoming price may go through dozen of checks that this price is not null (or symbol it related to). Yes, dozen times! Damned org.springframework.util.Assert.* calls were everywhere. Just because application was written by many developers and each one decided to check input parameter(s) on each method entrance, on each f..n layer. I pretty sure that happen not only to me. Just have a look at the stack trace of your code, you may found similar cases on some of an execution paths. Especially if you uses Spring.
Yeah, it could be the my fault. Just a case of cognitive dissonance, but last time the insidious thought creeps my mind: continuous using of Spring may hurt. Let's have a look why the old fashion JDK assertions may be very attractive and I would encourage people to use them more broadly.