cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Peters <port...@portnoy.org>
Subject Re: Coding style question: backwards null checks
Date Fri, 07 Mar 2003 18:05:04 GMT
Tony Collen <tcollen@neuagency.com> writes:

> Likewise, I've seen something like this in code... can't remember if it's
> anywhere in Cocoon:
> 
> if ( "something".equals(stringToCompare) {

[ versus... ]

> if ( stringToCompare.equals("something") ) {
> 
> Is this just a matter of style as well?  The first way seems goofy if you
> ask me.

Well, the first form works even if stringToCompare is null, the second
one will raise an exception in that case.

-- 
Stephen L. Peters                                  portnoy@portnoy.org
  GPG fingerprint: A1BF 5A81 03E7 47CE 71E0  3BD4 8DA6 9268 5BB6 4BBE
     "Poodle: The other white meat." -- Sherman, Sherman's Lagoon

Mime
View raw message