I'm a CFC newbie as well and that helps alot. Thanks Sean. I might be wrong, but I don't remember seeing that distinction in any of the DevNet articles. I wonder why that is.
Is it correct that <cfobject> or createObject is the only way to instantiate a stateful CFC, and that <cfinvoke> simply calls a method of a stateless CFC? Also, is this discussion of 'stateful' vs 'stateless' CFCs what the heated "scalability/MVC" discussion was in reference to? That 'stateful' CFCs require more overhead than 'stateless' ones? Finally, can someone provide a practical example of when 'stateful' CFCs would be particularly useful? Thanks! -----Original Message----- From: Barney Boisvert To: [EMAIL PROTECTED] Sent: 7/25/2003 7:38 PM Subject: RE: [CFCDev] Stateful vs stateless (was: CFC Caching Note that stateless CFCs are not necessarily called statically, they can be instantiated and cached, and usually are. So stateful/stateless is a different distinction from static/instantiated, although the two exhibit some parallels. --- Barney Boisvert, Senior Development Engineer AudienceCentral [EMAIL PROTECTED] voice : 360.756.8080 x12 fax : 360.647.5351 www.audiencecentral.com > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Sean A Corfield > Sent: Friday, July 25, 2003 3:27 PM > To: [EMAIL PROTECTED] > Subject: [CFCDev] Stateful vs stateless (was: CFC Caching > > > On Friday, Jul 25, 2003, at 11:48 US/Pacific, Paul Johnston wrote: > > I hate to say... Being a newbie at CFC's and all, there is a lot of > > mention > > of stateful CFC's etc... Ways of avoiding it and encapsulation etc... > > > > Anyone care to explain these to a humble newbie like me please? > > A stateful instance remembers information between invocations of > methods: > > <cfset stateful = createObject("component","foo") /> > ... > <cfset stateful.remember("some data") /> > ... > <cfset memory = stateful.reminder() /> > ... memory is "some data" ... > > And inside the CFC you use either "this" scope or the unnamed scope to > store the data (the latter is better practice): > > <cfcomponent> > <cffunction name="remember"> > <cfargument name="info"> > <cfset my_data = arguments.info> > </cffunction> > <cffunction name="reminder" returntype="any"> > <cfreturn my_data> > </cffunction> > </cfcomponent> > > Stateful CFCs therefore have a notion of 'history' - the behavior and > result of a method call is often dependent on the sequence of method > calls that have already been made to that instance. > > A stateless CFC doesn't store information, it provides services. The > behavior and result of a method call does not depend on the sequence of > method calls that have already been made to that instance (caveat: if > the methods access external 'state', such as a database, then clearly > there is a history but it's database history and not a history of the > component itself). > > HTH, > Sean A Corfield -- http://www.corfield.org/blog/ > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
