You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leo Simons <le...@apache.org> on 2003/03/07 20:38:54 UTC
[ot] Re: Coding style question: backwards null checks
We had a two-hour discussion on this the other day! (though we watched a
movie in between :D) It makes sense in C and C++. It also makes sense to
people for whom C and C++ makes sense.
The main arguments we found for using or not using
null == blah
0 == blah
MY_CONSTANT == blah
in java:
1) it is common practice in C/C++
2) it is not common practice in C/C++
3) it is common practice in java
4) it is not common practice in java
5) it makes code verification easier in an editor (for example, if you
use an editor made for C++ it might find the '=' error in the
null = blah setup, and not the other way around)
6) the meaning of what you are doing is more clear, since you
are testing whether a constant is the thing you just found
7) the meaning of what you are doing is less clear, since you
are testing whether an object equals a constant and not the
other way around
8) it is not common practice in textbooks (for some reason, we
couldn't think of a textbook that does it this way; though
I'm sure there must be)
1-4 are really the most important argument (any way you put it, it makes
life easier if we are all used to the same thing :D), but no-one
bothered checking. In the end we found that null == blah became more
plausible with the amount of beer consumed, so I say we keep doing it in
avalon :D
cheers!
- Leo
Johan Sjöberg wrote:
> Berin Loritsch wrote:
>> Jeff Turner wrote:
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: [ot] Re: Coding style question: backwards null checks
Posted by Johan Sjöberg <jo...@avaintec.com>.
Leo Simons wrote:
> In the end we found that null == blah became more
> plausible with the amount of beer consumed, so I say we keep doing it in
> avalon :D
Ahh, good point! I never though of that, and I see you have done some
proper investigation too.
I must now start changing these in my own code so I can enjoy a few more
beers before I quit coding. ;) Have a nice weekend.
Cheers,
//
Johan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org
Re: [ot] Re: Coding style question: backwards null checks
Posted by Berin Loritsch <bl...@apache.org>.
Leo Simons wrote:
> in java:
>
> 1) it is common practice in C/C++
> 2) it is not common practice in C/C++
> 3) it is common practice in java
> 4) it is not common practice in java
>
> 1-4 are really the most important argument (any way you put it, it makes
> life easier if we are all used to the same thing :D), but no-one
> bothered checking. In the end we found that null == blah became more
> plausible with the amount of beer consumed, so I say we keep doing it in
> avalon :D
Sounds good to me!
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org