Return-Path: Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 42686 invoked by uid 500); 7 Mar 2003 18:58:22 -0000 Mailing-List: contact dev-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon Developers List" Reply-To: "Avalon Developers List" Delivered-To: mailing list dev@avalon.apache.org Received: (qmail 42662 invoked from network); 7 Mar 2003 18:58:21 -0000 Received: from kura.mail.jippii.net (195.197.172.113) by daedalus.apache.org with SMTP; 7 Mar 2003 18:58:21 -0000 Received: from avaintec.com (unknown [195.197.158.226]) by kura.mail.jippii.net (Postfix) with ESMTP id 32C6323F7E8 for ; Fri, 7 Mar 2003 20:58:25 +0200 (EET) Message-ID: <3E68EBC9.4010608@avaintec.com> Date: Fri, 07 Mar 2003 20:58:17 +0200 From: =?ISO-8859-1?Q?Johan_Sj=F6berg?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Avalon Developers List Subject: Re: Coding style question: backwards null checks References: <20030307141624.GE3905@expresso.localdomain> <3E68AAB0.8020206@apache.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Berin Loritsch wrote: > Jeff Turner wrote: >> So is there any other reason for this? Can I do a massive grep for >> 'null !=' and change these? > > > No, I think that is the major reason. I remember a discussion between Peter D. and someone here on the list about this. I can't find it in the web archive so I include it from my local history. It might not be interesting though. At 08:24 1/12/00 -0500, you wrote: >Just a stylistic nit-pick: > >I noticed you committed a change that does nothing >but change the style of the code. Let me explain >why I do it the way I do. > >regarding "if (null != message) ...": > >to me this is not semantically correct, it is kind >of backwards. We are not checking if null is >message, but if message is null. I also think that >by keeping it "if (message != null) ..." it is more >readable and understandable by most English speaking >folks. I used to agree .. thou apparently we are wrong ;) (Had an argument with a professor over this one time ;] ) The reason basically comes down to expectations. "if( XXX == ... )" where XXX is any immutable-constant (like integer values, floats, nulls) is meant to facilitate understanding. It helps you understand the difference between "constants" and l-vars (or whatever they are called). Students who were taught "if( XXX == ... )" gain a "deeper" understanding of programming language. In some languages (namely c/c++) it also has added benefit of using compiler to check you don't have single '=' etc - thou this is for all purposes not relevent to java. Cheers, Pete Perhaps there is something to that, but ( null == arg ) still twists my head after some time spent on reading Avalon code ;) Cheers, // Johan --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org