Does order really matter? I admit this topic is probably a bit too wide. So lets put it in more precise way.
Does the order of condition within one single block of if statement matter on Java? Ordinary if statement can be written like this:
Computation only triggered when both condition met. So does the order matter? Cuz both condition gonna be examine for check anyway. This is what I thought till saw an article on D-zone week before.
It turn out the order does matter giving a situation that its costly for proceed both validation and crossCheck. And JVM is smart enough to stop as validation return false, cuz there is no way to have a true as return when either side in such situation. So in this case crossCheck won’t be triggered at all if validation return false.
This allow u to save resources when function CrossCheck ( ) actually expensive like: crosscheck need to fire a DB connection or RPC to process.
That’s I won’t execute both method call and both result into if statement for examination cuz extra work is done in some case.