cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hunsberger, Peter" <Peter.Hunsber...@stjude.org>
Subject RE: Coding style question: backwards null checks
Date Fri, 07 Mar 2003 17:50:34 GMT
Tony Collen <tcollen@neuagency.com>

> Likewise, I've seen something like this in code... can't 
> remember if it's anywhere in Cocoon:
> 
> if ( "something".equals(stringToCompare) {
>    ...
> }
> 
> IMO it seems more straightforward and easier to read if it's:
> 
> if ( stringToCompare.equals("something") ) {
>    ...
> }
> 
> Is this just a matter of style as well?  The first way seems 
> goofy if you ask me.
> 
> 
> Tony
> 

That's a common Java coding idiom: if "stringToCompare" is null things don't
blow up at run time.  It seems goofy, but in this case it makes sense...


Mime
View raw message