Gotcha, that makes sense :). I'm used to Get, Set and Let in VBScript objects, just seemed odd to write methods to get and set variables. Gotta twist my brain to a new way of thinking in this case.
Dan > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert > Sent: Wednesday, November 10, 2004 10:27 AM > To: [EMAIL PROTECTED] > Subject: Re: [CFCDev] How to define a property on a CFC > > I'd consider it bad, because any code can modify variables in the THIS > scope. Generally much better to use a getter, though there are > certainly exceptions. > > If you do use 'this', then you need to make sure that your CFC's > internal workings don't depend on the value, because there's no > guarentee that it'll be what it "should" be. > > cheers, > barneyb > > On Wed, 10 Nov 2004 10:19:59 -0800, Daniel Short > <[EMAIL PROTECTED]> wrote: > > That seems like an inordinate amount of code for just > setting and returning > > properties. I decided to play with the THIS scope, and came > up with this: > > > > <cfcomponent> > > > > <cffunction name="init"> > > <cfset THIS.hasError = false> > > </cffunction> > > > > <cffunction name="mymethod"> > > <cftry> > > <!--- some bad code ---> > > <cfcatch> > > <cfset THIS.hasError = true> > > </cfcatch> > > <cftry> > > </cffunction> > > </cfcomponent> > > > > Then in the calling page, I have this: > > > > <cfobject component="cfc/mycfc" name="mycfc"> > > <cfinvoke component="#mycfc#" method="init"> > > <cfinvoke component="#mycfc#" method="mymethod"> > > <cfoutput>#mycfc.hasError#</cfoutput> > > > > Am I doing anything illegal or bad there? I had heard that > the THIS scope > > was available outside the CFC, but I assumed that meant via > the THIS scope, > > which I found to be not true. Just trying to figure out if > I might run into > > a problem I'm not seeing by doing things this way. > > > > Thanks, > > > > Dan > > > -- > Barney Boisvert > [EMAIL PROTECTED] > 360.319.6145 > http://www.barneyb.com/blog/ > > I currently have 0 GMail invites for the taking > ---------------------------------------------------------- > 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 > [EMAIL PROTECTED] > > ---------------------------------------------------------- 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 [EMAIL PROTECTED]
