IsDedfined (was [thelist] Friday Freebie)

chris at fuseware.com chris at fuseware.com
Tue Dec 26 23:02:34 CST 2000


Again, Jeff is not here, but I think it is better to define it early, check
for errors early, and handle the erros early.  Later in your code, whether
modules or not, you merely have to check if the values are correct.

I don't agree that IsDefined isn't necesary.  CF almost defines itself by
offering multiple ways to accomplish the same task.  That is its strength
and its weakness. Most coders will thank the gods that IsDefined() ( or
ParameterExists() ) is defined ( or exists ).  I use it more than I would
like.  I do agree that variables used in a template should be defined in
advance, tested for veracity, errored on failure, and then passed into the
application.


Chris Evans
chris at fuseware.com
http://www.fuseware.com



-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Raymond Camden
Sent: Tuesday, December 26, 2000 10:00 PM
To: thelist at lists.evolt.org
Subject: RE: [thelist] Friday Freebie


Well, certainly, in cases where you can require input, you should. For
example, custom tags, but there are many example of cases where you can't
always be sure you will have the correct input. The example I used in my
email, a 'details' page, is a perfect example of that. When it comes to
readability, to me, this is much better:

<CFIF NOT IsDefined("URL.ID") OR NOT IsNumeric("URL.ID")>
	<CFLOCATION ...>
</CFIF>

compared to:

<CFTRY>
	<CFPARAM NAME="URL.ID" DEFAULT="0" TYPE="Numeric">
	<CFCATCH TYPE="Any">
		<CFLOCATION ..
	</CFCATCH>
</CFTRY>
<CFIF NOT URL.ID>
	<CFLOCATION ..>
</CFIF>

I guess it comes down to taste. Now, I still take issue with him saying
IsDefined() is not really necessary. You could also say CFLOOP isn't
necessary (just write your code constructs N times :), but you certainly
should use the tools you have at hand.

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Allaire

Email   : jedimaster at allaire.com
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of chris at fuseware.com
> Sent: Tuesday, December 26, 2000 8:57 PM
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] Friday Freebie
>
>
> I think Jeff's point ( and I agree) is that most typed languages require a
> variable definition. It makes it easier to write modular code if you know
> the inputs and outputs.  Using CFPARAM rather than IsDefined() brings you
> closer to a stronger typed, and more modular language.
>
>
> Chris Evans
> chris at fuseware.com
> http://www.fuseware.com
>
>
>


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !






More information about the thelist mailing list