I was always taught in my first job as a Java developer to avoid using "! =", But instead use an empty if clause, then put the logic in else:
if (x != null) {
}
if (x == null){
} else {
}
Our leading developers reasoned about avoiding an unnecessary bit switch, especially for simple logic, for example, to check for zero.
I have searched for sources that talk about this, but I cannot find them. Is the procedure โemptyโ if the proposal is really โbest practiceโ or just preference?
source
share