java - null==instance instead of instance==null -
this question has answer here:
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:
- it's clever , cool.
- 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:
- the object empty.
- empty object.
the former sounds more natural me.
Comments
Post a Comment