java - null==instance instead of instance==null -


i have seen @ many 3rd party code fragments in condition null==instance in used instead of instance==null if(null== connection).

just curious, approach makes impact on conditional statements or people cool use it?

the common reasons hear quoted using are:

  1. it's clever , cool.
  2. it helps protect against assignment vs. comparison errors, since can't assign null.

i vehemently argue against former, since "clever" becomes "difficult maintain" in codebase. latter has validity, though think decent test coverage can accomplish same task more added value.

personally don't care style because doesn't read correctly me. code "read prose" make easy follow. , consider 2 prose statements:

  1. the object empty.
  2. empty object.

the former sounds more natural me.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -