structKeyExists(application, "myObj") is generally considered the best
way. It's far more efficient than isDefined, as well as having far
less ambiguity about what you're testing.
I'd recommend, however, initializing all your application scope
objects at once, probably via a ColdSpring factory. Initialize the
factory once, and then let ColdSpring take care of making sure all the
other objects are singletons (or not, if that's how you've configured
them).
cheers,
barneyb
On 3/7/06, Martin Thorpe <[EMAIL PROTECTED]> wrote:
> Hello all.
>
>
>
> What is the best, recommended/practice, way to detect if an object,
> component, exists. For instance loading an object into the application
> scope you only need to load it if it is no longer defined. So I guess
> you could do this but would it be the best approach:
>
>
>
> <cfif NOT isdefined("application.myObj")>
>
> <!--- code to create and instantiate the object --->
>
> </cfif>
>
>
>
> thanks for reading.
>
> Cheers
>
> Martin
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/
Got Gmail? I have 100 invites.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234471
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54