Hey Kids,
An interesting spin / discussion recently came out of a post on Ray the god-like Coldfusion jedi's blog.
http://www.coldfusionjedi.com/index.cfm/2009/1/22/Why-you-should-and-should-not-break-encapsulation-in-methods
For me the interesting point was the code i've included at the bottom of this page. This is code i recently used in a webservice. As Ray Camden mentioned the lclApi will be re-created on every function call. This seems like a crazy way to code as it'll obviously be a performance hit for every function call. I had thought of putting the cfc instantiation in the server scope....but wasn't sure if that was propper form. There i ran out of ideas.
Anyway, Ray suggested coldSpring but that may be overkill for something so small as one webservice.
So over to you guys, anyone got any better suggestions?
<cfcomponent>
<cfset this.DSN = "mydsn" />
<!--- local complonent, being paranoid but i want to hide db code from the front facing cfc, this is re-created on every webservice call :(--->
<cfset this.lclApi = CreateObject("component","foo.apiPrivateMethods").init(this.DSN)
/>
<cffunction name="getUserDetails" access="remote" returntype="xml" output="false">
....
</cffunction>
</cfcomponent>