> If I load CFC's into my application scope using create object, should they
only contain methods and not properties, as any properties altered by one
user would affect all
other users accessing the cfc?

Not neccessarily, no. There are plenty of objects that might belong in the
application scope that have properties as well as methods. For example,
there is a last.fm API that requires an application key and secret key to
access it. If you were to create a CFC to wrap that API,
'lastFmApiService.cfc' for example, you would want to pass your application
key and secret credentials when you create an instance of the object. The
app and secret keys would be properties and these would remain constant
throughout the life of the application.

These kind of objects are known as 'Singletons' (its a slight misuse of the
term, but close enough). A Singleton would be a cfc that has a single
instance per application, i.e. sit in the application scope. A non-singleton
would have disposable instances that are created ad-hoc, perhaps per request
or per session.

Identifying your singletons and non-singletons may be a useful excersize and
once done, would be a good primer to start looking at ColdSpring (for
managing your singletons). Using onApplicationStart however, is a sound way
to go.

HTH

Dominic

On 19 February 2010 08:25, crippe crippe <crippe...@hotmail.com> wrote:

>
> Ah right, ok. So a follow up question:
>
> If I load CFC's into my application scope using create object, should they
> only contain methods and not properties, as any properties altered by one
> user would affect all other users accessing the cfc?
>
> Additionally, once you've instantiated a copy into the application scope,
> is their any way to instantiate a new copy from that copy, as CreateObject
> function seems to want the name of the CFC as oppossed to the actual cfc and
> what is loaded into application scope is the entire cfc object (without any
> kind of "name" string)?
>
> Sorry for all the n00b questions but I am still trying to wrap my head
> around OOP. I used to just access everything via application[property_name]
> now it seems I am creating new copies of it for every user request. Seems
> like a lot of extra memory being hogged, but "encapsulation is a good
> thing", right???
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330936
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to