On Monday, Nov 11, 2002, at 05:56 US/Pacific, Jeffry Houser wrote:
> bad practice to me.  I do see it often enough, such as checking for the
> length of a string like this:
>
>   <cfif Len(MyString)>
>          Whatever
>   </cfif>
>
>   It annoys me, because I would much rather see:
>
>   <cfif (Len(MyString) is 0)>
>          Whatever
>   </cfif>
>
>   The second is much more readable, in my opinion.

And you reinforce my point by making exactly the error I highlighted: 
your two conditions are the opposite of each other.

I agree that explicitly comparing integer expressions to an integer 
makes it clearer. We both find the first condition harder to read (I 
look at it and think "if len(myString) is true? what does that mean? 
ah, yes, myString is not empty") whereas the second expression is much 
clearer (in this case saying "if length of myString is zero, i.e., 
myString IS empty"!).

The long-hand expression just gets a little dangerous when you compare 
'expr' against 'true' (for the reasons stated - 'expr' might yield 2 
which is not equal to true!).

BTW, the isXxxx (or hasXxx) notation is just about the only naming 
prefix that I feel makes code more readable and (I believe) it is 
mentioned in the WTG Coding Guidelines I published. To me (and my 
team!) it's all about making the code read like English. "if ( 
isEmpty(myString) ) ..."

"SOAP is not so much a means of transmitting data
  but a mechanism for calling COM objects over the Web."
-- not Microsoft (surprisingly!)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to