I've seen in several places that a way to avoid null pointer exceptions is to switch the order of the equals operator. For example, using
Instead of:
Although this seems like a good idea, doesn't this make it harder to debug down the line if you run into problems? Isn't is basically hiding the fact that you have a NPE where you shouldn't?
In my opinion, you should only write this code if otherwise you would have written In other words, if you already intended to have the null check in place.