> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf > Of Joe Rinehart > Sent: Friday, January 20, 2006 8:29 AM > To: [email protected] > Subject: Re: [CFCDev] Bean and CFC question > > > > why am I writing separate getters and setters when I no longer am > concerned > > > about pseudo-static typing? So, I wrote universal get(propertyName) > and > > > set(propertyName, value) methods for BaseComponent.cfc. > > > > My initial reaction was "yuck!" until I saw your caveat about > > detecting and calling getX() if it is defined. That's pretty sweet. > > Ugh, I'm still against it. It allows (at least a portion of) your > CFC's private scope to be manipulated directly, essentially tossing > out the whole of data hiding.
In my implementation you can define properties before hand and the generic getter/setter will honor those definitions. Here's the tutorial page on that: http://www.depressedpress.com/Content/Development/ColdFusion/DPLibraries/Art icles/Tutorial_DPCFCs/Step2.cfm Properties are defined via the common function setPropDPMetaData() which is contained in the defineProps() method. Properties can be defined with an "Access" attribute which can be one of four values (this is straight ): +) "Public" properties are accessible directly (they are containing the component's "this" scope) using dot notation (component.property). Public properties do not need to be documented via setPropDPMetaData() to function, but it is recommended that you do so. +) "Abstract" properties (also called "DP Properties") are contained in the component's variable scope and are accessed via the getProp("propertyname") method and modified via the setProp("propertyName", propertyValue) method. These properties must be defined using setPropDPMetaData(). +) "Static" properties are accessible via the getProp("propertyname") method but can not be modified using the setProp("propertyName", propertyValue) method. These properties must be defined using setPropDPMetaData(). +) "Private" variables are contained the component's variables scope and are not accessible outside of it. They are documented using setPropDPMetaData() simply for the sake of completeness. Of course you could define a "Private" variable and still create a getter/setter for it - but that's against the recommendation. You could also override the generic functions directly... and that's REALLY against recommendation. ;^) In my case the "setProp()" and "getProp()" methods both follow the definition and enforce it. The "setProp()" method also does type validation (using the same types available to CFPARAM). So if you're setter would only do type validation on its own then this is a (I think) nice way to do that without a lot of clutter. At any time if you DO write a dedicated setter it will be used instead. So far this seems to be working well... even performance-wise. I used the framework on last year's FirstNight.org website and had no noticeable problems under some pretty severe load. I'm sure it does slow things down but it's not something I've been avble to notice. Jim Davis ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
