On Apr 21, 2004, at 12:53 PM, Paul Kenney wrote:
   <cfcomponent name="foo">
      <cfset variables.shared = StructGet("session.shared.foo")>

      <cffunction name="getBar" returntype="string" access="public">
         <cfreturn shared.bar/>
      </cffunction>
   </cfcomponent>

I'm a little confused by this example...


I'm not sure why you use StructGet("session.shared.foo") - don't you mean just session.shared (i.e., bind variables.shared to session.shared - which should already exist as a struct).

Otherwise your getBar() method will return session.shared.foo.bar (or, more likely, an error)?!?

BTW, I would be consistent with the scope prefix:

<cfreturn variables.shared.bar />

Personally, I think this sort of aliasing is a Bad Thing(tm) for several reasons: 1) CFCs shouldn't depend on shared scopes (i.e., their environment) unless they are specifically acting as a fa�ade for data in the shared scope; 2) aliasing a stateful CFC onto a session scope variable creates two names for the same thing which could cause maintenance problems; 3) your stateful CFC cannot be stored in application or server scope (a Session Fa�ade should be a stateless CFC that accesses session scope on-demand and therefore it can be stored in application scope since it is a service CFC).

Sean A Corfield -- http://www.corfield.org/blog/

"There are no solutions, only trade-offs."
-- Thomas Sowell

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to