RE: Coding style question: backwards null checks

2003-03-09 Thread Noel J. Bergman
> NB my stanza for repeatedly writing non-null checks is: > if( stringToCompare == null ) > stringToCompare = ""; > if( stringToCompare.equals("something") ) { > ... > } becomes: 0 aload_0 1 ifnonnull 7 4 ldc #2 6 astore_0 7 aload_0 8 ldc #3 10 invokevirtual #4

Re: Coding style question: backwards null checks

2003-03-09 Thread Stephen Peters
Tony Collen <[EMAIL PROTECTED]> 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

RE: Coding style question: backwards null checks

2003-03-08 Thread Nathaniel Alfred
> -Original Message- > From: Berin Loritsch [mailto:[EMAIL PROTECTED] > Sent: Freitag, 7. März 2003 18:50 > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: Coding style question: backwards null checks > > > if ( "something".equals(stringToCompar

Re: Coding style question: backwards null checks

2003-03-07 Thread Stefano Mazzocchi
Tony Collen wrote: On Fri, 7 Mar 2003, Berin Loritsch wrote: Jeff Turner wrote: 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. Likewise, I'

Re: Coding style question: backwards null checks

2003-03-07 Thread Berin Loritsch
Jeff Turner wrote: 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 conditio

Re: Coding style question: backwards null checks

2003-03-07 Thread Antonio Gallardo
> On Fri, 7 Mar 2003, Berin Loritsch wrote: > >> Actually, this *does* have a purpose. In the event that >> stringToCompare is null, then you would get spurious >> NullPointerExceptions that are not always easy to trace. > > O > > The things they just don't teach you in class :) What clas

Re: Coding style question: backwards null checks

2003-03-07 Thread Marcus Crafter
On Fri, Mar 07, 2003 at 12:44:04PM -0500, Tony Collen wrote: > > 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 (

Re: Coding style question: backwards null checks

2003-03-07 Thread Tony Collen
On Fri, 7 Mar 2003, Berin Loritsch wrote: > Actually, this *does* have a purpose. In the event that > stringToCompare is null, then you would get spurious > NullPointerExceptions that are not always easy to trace. O The things they just don't teach you in class :) *puts into bag of tri

RE: Coding style question: backwards null checks

2003-03-07 Thread Hunsberger, Peter
Tony Collen <[EMAIL PROTECTED]> > 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("somet

Re: Coding style question: backwards null checks

2003-03-07 Thread Berin Loritsch
Tony Collen wrote: On Fri, 7 Mar 2003, Berin Loritsch wrote: 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(

Re: Coding style question: backwards null checks

2003-03-07 Thread Tony Collen
On Fri, 7 Mar 2003, Berin Loritsch wrote: > Jeff Turner wrote: > > 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

Re: Coding style question: backwards null checks

2003-03-07 Thread Antonio Gallardo
Good point. I was asked myself why they used this construction. Nice answer. I think it can be changed too. Antonio Gallardo > Hi, > > Quick question. Why do people put null checks backwards: > > if ( null != this.inputSource ) { > > IMHO it is harder to read than > > if ( this.inputSource

Re: Coding style question: backwards null checks

2003-03-07 Thread Berin Loritsch
Jeff Turner wrote: 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. Yep. I think this is a throwback from the days of C, where swapping the con