Hi,

I think that your statement about using cfparam sums it up well.  It is all
about code design.  If all you variables are declared and initialised at the
beginning of a template, custom tag, function or cfc then it improves
readability and maintainability.  It helps to ensure that you have thought
about each variable you are using and also, I find, that it reduces reuse of
the same variable for cross purposes.  Imagine if you have some code that
uses isDefined and you are relying in the fact a variable exists to take
some action.  Then later some else comes along and uses the same variable
name in another template.  Woops. Code broken.  If you "parametrise" and
initialise your variables at the start of your template it is easier to read
and less chance of conflict with other code.  I would much rather "know"
that a variable exists and see what values it contains than hope it exists.

It also cuts down you coding as you only have to say

<cfif x eq "somevalue">
  ....
</cfif>

rather than

<cfif isDefined("x" and  x eq "somevalue">
  ....
</cfif>


Anyway.  That is a very quick reason and something that I could rant on
about for ages but hopefully gives a little idea about why I don't like
isDefined.

I have not come across a reason to use isDefined accept in an error handler.

On 08/12/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
>
>  Well I'll put my hand up as being guilty of using IsDefined(), but prefer
> to use cfparam where it really matters.
>
>
>
> Why is IsDefined frowned upon though?
>
>
> Andrew Scott
> Senior Coldfusion Developer
> Aegeon Pty. Ltd.
> www.aegeon.com.au
> Phone: +613  8676 4223
> Mobile: 0404 998 273
>   ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Simon Haddon
> *Sent:* Friday, 8 December 2006 12:03 PM
> *To:* [email protected]
> *Subject:* [cfaussie] Re: Talking of evaluate()
>
>
>
> Totally agree about isDefined.
>
> It is one function that I wish was never created.  The number of times it
> has caused grief I have lost count of.  Not the the function itself is wrong
> it is just that it is badly used within alot of code.
>
> Cheers,
> Simon
>
>
>
> >
>


-- 
Cheers
Simon Haddon


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to