cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <je...@apache.org>
Subject Coding style question: backwards null checks
Date Fri, 07 Mar 2003 14:16:24 GMT
Hi,

Quick question.  Why do people put null checks backwards:

  if ( null != this.inputSource ) {

IMHO it is harder to read than

  if ( this.inputSource != null ) {

and means exactly the same thing.


I think this is a throwback from the days of C, where swapping the
conditions was a handy way to avoid =/== bugs like:

  if ( this.inputSource = null ) {

But in Java, the compiler catches this error:

Found 1 semantic error compiling "Test.java":

    10.                 if (inputSource = null) {
                            <---------------->
*** Error: The type of this expression, "Source", is not boolean.


So is there any other reason for this?  Can I do a massive grep for 
'null !=' and change these?


--Jeff

Mime
View raw message