It's mind bending experiencing reading code like :
I was unsuccessful in trying to talk the person out of this style, maybe I'm wrong? Or maybe I wasn't articulate enough, hence the post here.
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
No, it's not justified.
It makes some sense to do this for string comparisons in Java where calling
.equals on a string variable can result in a NullPointerException, so:
Can be made safer by doing:
This is not really relevant in C# which uses the
== operator for string comparisons. This is safe to use with null references. The same is true of