- see footer for list info -<
Become familiar with them and you'll feel good all over :)

As for your question, if a a variable is set in the variables scope in a component, the variable is only accessable by the component instance. So you'd set variables.myQuery in the example method, then have another method in the component that returns variables.myQuery.

I'd be interested to know the details of this example so we could see how it could be OO :)


Dom


Gary F wrote:

- see footer for list info -<
As I'm unfamiliar with OOP principles I don't feel bad if I ignore them. :-)
So long as using This doesn't expose any mechanical issues such as memory or
security problems then I'll probably stick with This. The CFC won't be
persistant or in any session/app scopes.

Simon, I'm interested in what you mean by setting them in the variables
scope and return them using separate getter methods? Does that mean
variables.myvar in a CFC is exposed to the parent page? I suspect you mean
something else.

Thanks,
Gary.

On 12/29/05, Simon Baynes <[EMAIL PROTECTED]> wrote:
- see footer for list info -<
Using the this scope is not bad practise it is just very loose, ie it
does not check data types etc.. That is why many people (including
myself) use it very rarely. Another reason is that this data is
intrinsically attached to the object you create whereas you can set
the result of a function call equal to a function call and then you
can use it for whatever you like.

So in summary there is nothing wrong with the this scope just that it
goes against the grain of many OOP principles.

For your above problem I would suggest returning a structure, or set
then in the variables scope within the object and return them using
separate getter methods.

I hope that clears some of it up for you.

Regards,

Simon Baynes

On 12/29/05, Gary F <[EMAIL PROTECTED]> wrote:
- see footer for list info -<
I posted a similar message on Ray Camden's Ask a Jedi blog but it
created
more questions than answers. I need to return at least 2 complex objects
(queries) from a CFC. The CFRETURN function only lets you return a
single
object/variable so I started using the THIS scope.

Example: from within the CFC
<CFSET this.myquery=myquery>

Now myquery is exposed to the parent page so I can grab it like so:

<!--- use createobject to initiate the cfc --->
<CFSET objCFC=CreateObject("component","myCFC")>
<!--- collect a varible that CFReturn would usually return from a cfc
--->
<CFSET getReturnedData=objCFC.myFunction("optional arguments go here")>
<!--- get the var/object that was explosed using the This scope --->
<CFSET myquery=objCFC.myquery>

I found this is the quickest and most effecient way to return multiple
vars/objects from CFCs without storing them in arrays or structures
which
seems like a waste of code when This works with total simplicity.
Someone
told me using the This scope is bad practice but failed to give a
reason. I
honestly don't see what's wrong with this, but I'd like to hear the
thoughts
of experienced CFC users? (I've only been using CFCs for a few months).

Thanks,
Gary.
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to
http://list.cfdeveloper.co.uk/mailman/listinfo
--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help
-<
--
Simon Baynes
www.simonbaynes.com
_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help
-<

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<


_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to