My only caveat with using #NOT Len(x)# inline with cfqueryparam is
that I typically don't like to use negative logic.

It was something that was taught to me by a much senior developer
during a code review during my first internship.  Typically using
positive logic is easier to read.

I think the idea of the isNull function is a good one - and Peter
makes a good modification to it in his condensation, even though in
there he is using negative logic.  Since it is enclosed in the isNull
wrapper function I actually don't mind it.

Each person/organization has their own style so it is up to you and
your preference; but I think I like the "isNull" function idea as
Peter wrote it.  It's short, concise, and hides the cumbersome logic.

Bill


On 7/14/05, Roland Collins <[EMAIL PROTECTED]> wrote:
> I use a nearly identical version of that for null strings and numbers.
> 
> I also use one for dates that uses our "magic" null date:
> 
> <cffunction name="IsNullDate" returntype="boolean" output="false">
>         <cfargument name="dt" type="string" required="true" />
>         <cfreturn (arguments.dt is "" or arguments.dt is "1/1/1950")>
> </cffunction>
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of Peter J. Farrell
> Sent: Thursday, July 14, 2005 11:05 AM
> To: [email protected]
> Subject: Re: [CFCDev] Handling NULL's in a DAO
> 
> Trevor Orr wrote:
> 
> >I wrote this function for handling NULLs.
> >
> ><cfqueryparam cfsqltype="cf_sql_integer"
> >value="#arguments.CustomerBean.getGuarantor()#"
> >null="#IsNull(arguments.CustomerBean.getGuarantor())#" />
> >
> >
> ><CFFUNCTION NAME="IsNull" returntype="boolean" OUTPUT="false">
> >       <CFARGUMENT NAME="Value" TYPE="String" REQUIRED="TRUE">
> >
> >       <CFSET var IsNull = FALSE>
> >
> >       <CFIF Trim(Arguments.Value) EQ "">
> >               <CFSET IsNull = TRUE>
> >       </CFIF>
> >
> >       <CFRETURN IsNull>
> ></CFFUNCTION>
> >
> >
> This function should run faster as the number of sets has been reduced
> to 0, CF doesn't have to make a comparison with EQ, no conditional
> statement and the code goes from six lines to one line.
> 
> <cffunction name="isNull" access="public" returntype="boolean"
> output="false">
>         <cfargument name="value" type="string" required="true" />
>         <cfreturn NOT len(arguments.value)>
> </cffunction>
> 
> Considering the what is in the function - I think that #NOT
> len(arguments.someBean.getSomeVar)# would be faster as you don't have to
> make a function call.   I usually prefer to make sure all my data is
> good (validated and trimmed etc) before my DAOs - so I left out a trim()
> in the function
> 
> Best,
> .Peter
> 
> --
> Peter J. Farrell :: Maestro Publishing
> 
> blog    :: http://blog.maestropublishing.com
> email   :: [EMAIL PROTECTED]
> 
> Create boilerplate beans!
> Check out the Mach-II Bean Creator - free download.
> http://blog.maestropublishing.com/mach-ii_beaner.htm
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
> 
> CFCDev is supported by New Atlanta, makers of BlueDragon
> http://www.newatlanta.com/products/bluedragon/index.cfm
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> 
> 
> 
> 
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to 
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the 
> email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
> (www.cfxhosting.com).
> 
> CFCDev is supported by New Atlanta, makers of BlueDragon
> http://www.newatlanta.com/products/bluedragon/index.cfm
> 
> An archive of the CFCDev list is available at 
> www.mail-archive.com/[email protected]
> 
> 
> 


-- 
[EMAIL PROTECTED]
http://blog.rawlinson.us

If you want Gmail - just ask.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to