[thelist] CF: Determining which DB used.
Joshua Olson
joshua at alphashop.net
Wed Sep 12 12:42:23 CDT 2001
: > through testing, it indeed appears that foo is created in the
: > server scope. however, you can't test that it exists using
: > StructKeyExists(server, "foo"). instead, you have to use an
: > IsDefined() instead -- yuck.
:
: Correct. This is expect since "Server" is not a valid Struct. However, I
: don't consider this yucky per se, if I were storing stuff in Server I'd
: just do:
:
: <CFIF NOT IsDefined("Server.Foo")>
: ... start setting crap up ...
: </CFIF>
:
: which is the same kind of code you use before setting application
: variables. (And if you DONT do this, you should!)
See, Ray, there is another way.
<cfparam name="Server.foo" default="">
<cfif NOT IsStruct(Server.foo)>
... start setting crap up ...
</cfif>
or
<cfparam name="Server.foo" default="#StructNew()#">
<cfparam name="Server.foo.bar" default="myval">
etc...
Lots and lots of ways around using IsDefined()
.jeff made all sorts of arguments against using IsDefined. Not that I
necessarily agree with him, but under most circumstances it is possible to
avoid using it and still have robust code. I have a project manager that is
very dogmatic about not using IsDefined so I've learned tricks around it and
have yet to find a situation that required it.
-joshua
More information about the thelist
mailing list