I'm not an OO expert, either (hardly!). But, in our case, we have lots of 
apps that all use the same basic DSN configurations, but each "stand alone" 
in terms of application structure. So, I'm using the approach of having a 
settings.cfc type thing (that can either use the default configurations or 
override them), and then passing that object to my local application objects 
in the init() call. I still get the advantage of only having one place per 
app where I set the settings.cfc info (usually in the app scope in my 
Application.cfm). So, if it changes I can change it in one place. AND, I can 
use it "outside the package" so to speak.

I'm still just learning all this, too. But, this seems to be working well 
for me, so far.

Example (stripping out all the cfif stuff):
In Application.cfm
<cfscript>
// create the settings object with the default settings
application.settings = createObject("component", "cfc.ces.DBData").init();

// create the survey object, passing in the settings object
session.thisSurvey = createObject("component", 
"ces.apps.360Review.cfc.survey").init(application.settings);
</cfscript>

In survey.cfc
<!--- Run a query --->
<cfquery name="getSurveydata" datasource="#variables.dbdata.getDSN()#" 
username="#variables.dbdata.getUsername()#" 
password="#variables.dbdata.getPassword()#">
...
</cfquery>





----- Original Message ----- 
From: "Raymond Camden" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, November 15, 2004 8:21 AM
Subject: Re: cfc - cffunction question


> Let me start by saying I am NOT an OO expert. PLEASE remember that. :)
>
> To me, this doesn't break encapsulation because the CFCs are all in
> the same package, so it makes sense that they would use one another.
>
> As for flip flopping, I hear ya. Every other app I make using CFCs
> does things a bit differently. You can see this clearly if you look at
> my DRK apps. I'm still trying to find the best way myself.
>
>
> On Sun, 14 Nov 2004 19:14:56 -0600, Dawson, Michael <[EMAIL PROTECTED]> 
> wrote:
>> Ray, doesn't this break encapsulation by putting the cfinvoke call
>> _inside_ another component?  I'm still trying to learn the OO way, and I
>> keep flip-flopping about best-practices and/or easier programming.
>>
>> M!ke
>>
>>
>>
>> -----Original Message-----
>> From: Raymond Camden [mailto:[EMAIL PROTECTED]
>> Sent: Saturday, November 13, 2004 5:55 PM
>> To: CF-Talk
>> Subject: Re: cfc - cffunction question
>>
>> But (normally), extends should only be used to create a "Is A"
>> releationship. Settings doesn't match this rule. Just in case it wasn't
>> too obvious for others, here is a super simple example of what I'm
>> talking about. Please note I did not include attributes like
>> output=false, hint, var statements, etc, just to make things tighter:
>>
>> settings.cfc:
>> <cfcomponent>
>>
>>     <cffunction name="getSettings" returnType="struct">
>>         <!--- set a bunch of vars, or load them from the db, or an xml
>> file, or whatever --->
>>         <!--- simple hard coded example here --->
>>         <cfset var settings = structNew()>
>>         <cfset settings.dsn = "moo">
>>         <cfreturn settings>
>>     </cffunction>
>>
>> </cfcomponent>
>>
>> foo.cfc:
>> <cfcomponent>
>>
>>     <cfinvoke component="settings'" method="getSettings"
>> returnVariable="variables.settings">
>>
>>     <cffunction name="getStuff">
>>         <cfquery name="stuff" datasource="#variables.settings.dsn#">
>>         select whatever
>>         </cfquery>
>>         <cfreturn stuff>
>>     </cffunction>
>>
>> </cfcomponent>
>>
>> What's nice then is that your Application.cfm can use the same cfinvoke
>> statement to get global settings, although it would use
>> returnVariable="application.settings". So now both your CFCs and your
>> outside code all use the same method to get their settings.
>>
>> On Sat, 13 Nov 2004 17:47:57 +0200, Murat Demirci <[EMAIL PROTECTED]>
>> wrote:
>> > For your specific situation you can use <cfmodule> in your
>> > cffunction(s) or develop a global component which creates
>> > variables.settings internally and extend it.
>> >
>> > Murat.
>> >
>> >
>> >
>> > > -----Original Message-----
>> > > From: Charles Heizer [mailto:[EMAIL PROTECTED]
>> > > Sent: Saturday, November 13, 2004 2:12 AM
>> > > To: CF-Talk
>> > > Subject: cfc - cffunction question
>> > >
>> > > Hello,
>> > > I was wondering if it was possible to do a cfinclude in a cffunction
>>
>> > > tag?
>> > >
>> > > I have a globals.cfm file which has site wide variables set and I
>> > > want to reference them with out using cfinvokeargument tag.
>> > >
>> > > I hope this make sense,
>> > > Thanks a bunch,
>> > > - Charles
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184271
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to