RE: CFC Best practices question

2008-03-05 Thread Rich
> If I have an object loaded in the Application scope and want to use it in
> another object/component ,should I pass it in as a variable or should I
> call
> it directly from the Application scope. Assume that the object will always
> be loaded in memory.
> 
> TIA
> G

I would advise against accessing the component directly.  As a general rule,
you should not have any CFC access a scope outside of itself.  I would
suggest one of the following two approaches: 

1. Use a façade to the application scope
By using a façade, only one component is tied directly to the application
scope.

2. Injection
Using either constructor or setter injection, pass the object in as a
variable.

HTH,
Rich Kroll


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300579
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: CFC Best practices question

2008-03-05 Thread Russ
Also don’t forget to var your variables.  Bad things happen when you don't
var variables that are meant to stay private to the function and you cache
your component. 

RUss

> -Original Message-
> From: Rich [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2008 4:53 PM
> To: CF-Talk
> Subject: RE: CFC Best practices question
> 
> > If I have an object loaded in the Application scope and want to use it
> in
> > another object/component ,should I pass it in as a variable or should I
> > call
> > it directly from the Application scope. Assume that the object will
> always
> > be loaded in memory.
> >
> > TIA
> > G
> 
> I would advise against accessing the component directly.  As a general
> rule,
> you should not have any CFC access a scope outside of itself.  I would
> suggest one of the following two approaches:
> 
> 1. Use a façade to the application scope
> By using a façade, only one component is tied directly to the application
> scope.
> 
> 2. Injection
> Using either constructor or setter injection, pass the object in as a
> variable.
> 
> HTH,
> Rich Kroll
> 
> 
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300580
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread Matt Williams
On Wed, Mar 5, 2008 at 3:43 PM, Gerald Guido <[EMAIL PROTECTED]> wrote:
> If I have an object loaded in the Application scope and want to use it in
>  another object/component ,should I pass it in as a variable or should I call
>  it directly from the Application scope. Assume that the object will always
>  be loaded in memory.

I vote for passing it in. It makes the component that will use it less
couple to application scope and therefore more reusable.

If several methods within the component are going to need access to
various methods in the application.myCFC object, then it would make
more sense to do what Rich says in step 2. Basically when the
component that is dependent on app.myCFC is instantiated, it should
get that instance in variables scope


  
 
  
  


  





-- 
Matt Williams
"It's the question that drives us."

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300582
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFC Best practices question

2008-03-05 Thread Gerald Guido
>> Also don't forget to var your variables.

Why is it that when you ask a CFC question people assume that you aren't
scoping your variables?


On Wed, Mar 5, 2008 at 5:01 PM, Russ <[EMAIL PROTECTED]> wrote:

> Also don't forget to var your variables.  Bad things happen when you don't
> var variables that are meant to stay private to the function and you cache
> your component.
>
> RUss
>
> > -Original Message-
> > From: Rich [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 05, 2008 4:53 PM
> > To: CF-Talk
> > Subject: RE: CFC Best practices question
> >
> > > If I have an object loaded in the Application scope and want to use it
> > in
> > > another object/component ,should I pass it in as a variable or should
> I
> > > call
> > > it directly from the Application scope. Assume that the object will
> > always
> > > be loaded in memory.
> > >
> > > TIA
> > > G
> >
> > I would advise against accessing the component directly.  As a general
> > rule,
> > you should not have any CFC access a scope outside of itself.  I would
> > suggest one of the following two approaches:
> >
> > 1. Use a façade to the application scope
> > By using a façade, only one component is tied directly to the
> application
> > scope.
> >
> > 2. Injection
> > Using either constructor or setter injection, pass the object in as a
> > variable.
> >
> > HTH,
> > Rich Kroll
> >
> >
> >
>
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300583
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFC Best practices question

2008-03-05 Thread Gerald Guido
I have seen it set in the init and set to the variables scope. and then
called from individual functions.

So if the passed object is local to *only one* function should I pass it to
just that one function?

Or if it used multiple times in the object I should store it as part of the
object (in the init function) in the variables scope so it can be avalible
to multiple functions.

Does that sound right... make sense?

Thanx
G

On Wed, Mar 5, 2008 at 5:07 PM, Matt Williams <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 5, 2008 at 3:43 PM, Gerald Guido <[EMAIL PROTECTED]>
> wrote:
> > If I have an object loaded in the Application scope and want to use it
> in
> >  another object/component ,should I pass it in as a variable or should I
> call
> >  it directly from the Application scope. Assume that the object will
> always
> >  be loaded in memory.
>
> I vote for passing it in. It makes the component that will use it less
> couple to application scope and therefore more reusable.
>
> If several methods within the component are going to need access to
> various methods in the application.myCFC object, then it would make
> more sense to do what Rich says in step 2. Basically when the
> component that is dependent on app.myCFC is instantiated, it should
> get that instance in variables scope
>
> 
>  
> 
>  
>  
>
>
>  
> 
>
>  />
> 
>
> --
> Matt Williams
> "It's the question that drives us."
>
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300585
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFC Best practices question

2008-03-05 Thread Charlie Griefer
I think you're starting to see where ColdSpring (or Lightwire) might
come in handy :)

On Wed, Mar 5, 2008 at 2:24 PM, Gerald Guido <[EMAIL PROTECTED]> wrote:
> I have seen it set in the init and set to the variables scope. and then
>  called from individual functions.
>
>  So if the passed object is local to *only one* function should I pass it to
>  just that one function?
>
>  Or if it used multiple times in the object I should store it as part of the
>  object (in the init function) in the variables scope so it can be avalible
>  to multiple functions.
>
>  Does that sound right... make sense?
>
>  Thanx
>  G
>
>
>
>  On Wed, Mar 5, 2008 at 5:07 PM, Matt Williams <[EMAIL PROTECTED]> wrote:
>
>  > On Wed, Mar 5, 2008 at 3:43 PM, Gerald Guido <[EMAIL PROTECTED]>
>  > wrote:
>  > > If I have an object loaded in the Application scope and want to use it
>  > in
>  > >  another object/component ,should I pass it in as a variable or should I
>  > call
>  > >  it directly from the Application scope. Assume that the object will
>  > always
>  > >  be loaded in memory.
>  >
>  > I vote for passing it in. It makes the component that will use it less
>  > couple to application scope and therefore more reusable.
>  >
>  > If several methods within the component are going to need access to
>  > various methods in the application.myCFC object, then it would make
>  > more sense to do what Rich says in step 2. Basically when the
>  > component that is dependent on app.myCFC is instantiated, it should
>  > get that instance in variables scope
>  >
>  > 
>  >  
>  > 
>  >  
>  >  
>  >
>  >
>  >  
>  > 
>  >
>  >   > />
>  > 
>  >
>  > --
>  > Matt Williams
>  > "It's the question that drives us."
>  >
>  >
>
>  

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300586
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread Gerald Guido
Yep... that light bulb just went off. thanx.

On Wed, Mar 5, 2008 at 5:29 PM, Charlie Griefer <[EMAIL PROTECTED]>
wrote:

> I think you're starting to see where ColdSpring (or Lightwire) might
> come in handy :)
>
> On Wed, Mar 5, 2008 at 2:24 PM, Gerald Guido <[EMAIL PROTECTED]>
> wrote:
> > I have seen it set in the init and set to the variables scope. and then
> >  called from individual functions.
> >
> >  So if the passed object is local to *only one* function should I pass
> it to
> >  just that one function?
> >
> >  Or if it used multiple times in the object I should store it as part of
> the
> >  object (in the init function) in the variables scope so it can be
> avalible
> >  to multiple functions.
> >
> >  Does that sound right... make sense?
> >
> >  Thanx
> >  G
> >
> >
> >
> >  On Wed, Mar 5, 2008 at 5:07 PM, Matt Williams <[EMAIL PROTECTED]> wrote:
> >
> >  > On Wed, Mar 5, 2008 at 3:43 PM, Gerald Guido <[EMAIL PROTECTED]>
> >  > wrote:
> >  > > If I have an object loaded in the Application scope and want to use
> it
> >  > in
> >  > >  another object/component ,should I pass it in as a variable or
> should I
> >  > call
> >  > >  it directly from the Application scope. Assume that the object
> will
> >  > always
> >  > >  be loaded in memory.
> >  >
> >  > I vote for passing it in. It makes the component that will use it
> less
> >  > couple to application scope and therefore more reusable.
> >  >
> >  > If several methods within the component are going to need access to
> >  > various methods in the application.myCFC object, then it would make
> >  > more sense to do what Rich says in step 2. Basically when the
> >  > component that is dependent on app.myCFC is instantiated, it should
> >  > get that instance in variables scope
> >  >
> >  > 
> >  >  
> >  > 
> >  >  
> >  >  
> >  >
> >  >
> >  >  
> >  > 
> >  >
> >  >  createObject('component','myDependentCFC').init()
> >  > />
> >  > 
> >  >
> >  > --
> >  > Matt Williams
> >  > "It's the question that drives us."
> >  >
> >  >
> >
> >
>
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300587
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread James Holmes
I'll second this. When you use ColdSpring, you end up having it passed
in as an init() parameter and then put it in the VARIABLES scope, so
it's available to all methods inside your object.

On Thu, Mar 6, 2008 at 7:29 AM, Charlie Griefer
<[EMAIL PROTECTED]> wrote:
> I think you're starting to see where ColdSpring (or Lightwire) might
>  come in handy :)
>
>
>
>  On Wed, Mar 5, 2008 at 2:24 PM, Gerald Guido <[EMAIL PROTECTED]> wrote:
>  > I have seen it set in the init and set to the variables scope. and then
>  >  called from individual functions.
>  >
>  >  So if the passed object is local to *only one* function should I pass it 
> to
>  >  just that one function?
>  >
>  >  Or if it used multiple times in the object I should store it as part of 
> the
>  >  object (in the init function) in the variables scope so it can be avalible
>  >  to multiple functions.


-- 
mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300588
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFC Best practices question

2008-03-05 Thread Dominic Watson
>
> I think you're starting to see where ColdSpring (or Lightwire) might
> come in handy :)


I second that - spend 30 mins getting a very basic ColdSpring setup running;
you won't look back, it is a beautiful answer to this question.

ColdSpring uses an XML file as a configuration for all your 'beans', here's
a very rough example, reusing a component by passing it as an argument to
another:



  MyDS



 
   
 

Then, with coldspring up and running you might do in your app:



Hope that makes you curious. If you are looking for best design practice,
the answer to your OP is to NEVER reference variables outside the scope of
your component, pass it in as a variable as your instinct tells you ;)

Dominic
-- 
Blog it up: http://fusion.dominicwatson.co.uk


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300589
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFC Best practices question

2008-03-05 Thread Gerald Guido
Thanx for the insight gentlemen. I am getting all wound up with the light
bulbs going off at once.

Prolly wont get much sleep tonight. :)


On Wed, Mar 5, 2008 at 5:42 PM, Dominic Watson <
[EMAIL PROTECTED]> wrote:

> >
> > I think you're starting to see where ColdSpring (or Lightwire) might
> > come in handy :)
>
>
> I second that - spend 30 mins getting a very basic ColdSpring setup
> running;
> you won't look back, it is a beautiful answer to this question.
>
> ColdSpring uses an XML file as a configuration for all your 'beans',
> here's
> a very rough example, reusing a component by passing it as an argument to
> another:
>
>
>  singleton="true">
>  MyDS
> 
>
> 
>  
>   
>  
> 
> Then, with coldspring up and running you might do in your app:
>
> 
>
> Hope that makes you curious. If you are looking for best design practice,
> the answer to your OP is to NEVER reference variables outside the scope of
> your component, pass it in as a variable as your instinct tells you ;)
>
> Dominic
> --
> Blog it up: http://fusion.dominicwatson.co.uk
>
>
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300594
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread Dominic Watson
>
> Thanx for the insight gentlemen. I am getting all wound up with the light
> bulbs going off at once.


Lol best bit of being a codee geek init ;)

Dominic
-- 
Blog it up: http://fusion.dominicwatson.co.uk


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300595
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread Gerald Guido
>> Lol best bit of being a codee geek init ;)

yep... nothing quite like the high from intellectual discovery. It is hard
to explain to non-geeks/science nerds.

GF: "Oh, what are you all excited about?"
Me: "I just figured out dependency injection".
GF: "Huh?"
Me: "Nothing."


-- 
"As an adolescent I aspired to lasting fame, I craved factual certainty, and
I thirsted for a meaningful vision of human life - so I became a scientist.
This is like becoming an archbishop so you can meet girls."
- M. Cartmill


~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300597
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFC Best practices question

2008-03-05 Thread Dominic Watson
Lmao, my gf would pretend to listen for a 10 minutes or more as I explained
things to her. At the end of the lecture she'd say "that's nice dear, what's
for tea?" or some such.


On 05/03/2008, Gerald Guido <[EMAIL PROTECTED]> wrote:
>
> >> Lol best bit of being a codee geek init ;)
>
> yep... nothing quite like the high from intellectual discovery. It is hard
> to explain to non-geeks/science nerds.
>
> GF: "Oh, what are you all excited about?"
> Me: "I just figured out dependency injection".
> GF: "Huh?"
> Me: "Nothing."
>
>
> --
> "As an adolescent I aspired to lasting fame, I craved factual certainty,
> and
> I thirsted for a meaningful vision of human life - so I became a
> scientist.
> This is like becoming an archbishop so you can meet girls."
> - M. Cartmill
>
>
> 

~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:300598
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4