Also, if you use a bean generator, be sure to proofread your code! Bean generators are good starting points, but should never be relied upon for final code. :)
On Nov 10, 2004, at 2:50 PM, Daniel Short wrote:
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 justsetting and returningproperties. I decided to play with the THIS scope, and cameup with this:the THIS scope
<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 thatwas available outside the CFC, but I assumed that meant viathe THIS scope,which I found to be not true. Just trying to figure out ifI might run intoa 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]
----------------------------------------------------------
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]
