Re: My Init() in my CFC...am I on the right track?

2005-01-04 Thread Troy Murray
Per Hal Helms himself- Yes, Troy. I've begun work on a new book, Designing OO Applications with ColdFusion CFCs that I hope will be helpful. -t On Thu, 30 Dec 2004 12:25:21 -0500, Jeff Small [EMAIL PROTECTED] wrote: Sean, Someone should contact Hal and see if he has plans to update the

Re: My Init() in my CFC...am I on the right track?

2004-12-30 Thread Jeff Small
On Wed, 29 Dec 2004 13:18:43 -0500, Jeff Small [EMAIL PROTECTED] wrote: Good lord this is a lot of...ahem...stuff to remember... Yeah, that's why it takes most folks years to become 'fluent' in OO design... Cool, something else to master...lol... There's some OO basics in the first few

Re: My Init() in my CFC...am I on the right track?

2004-12-30 Thread Rick Mason
Sean, Someone should contact Hal and see if he has plans to update the book for Blackstone. That book got me started on CFC's and I bet that a lot of people on this list would purchase the sequel. Rick Mason On Thu, 30 Dec 2004 09:53:20 -0500, Jeff Small [EMAIL PROTECTED] wrote: On Wed,

Re: My Init() in my CFC...am I on the right track?

2004-12-30 Thread Jeff Small
Sean, Someone should contact Hal and see if he has plans to update the book for Blackstone. That book got me started on CFC's and I bet that a lot of people on this list would purchase the sequel. Rick Mason Dude...sign me UP. I'm getting tired of scouring bookmarks...lol. Even with

Re: My Init() in my CFC...am I on the right track?

2004-12-30 Thread Sean Corfield
On Thu, 30 Dec 2004 09:53:20 -0500, Jeff Small [EMAIL PROTECTED] wrote: Just a quick Question, then I'm off to go program for days...do you or anyone else know if Hal's planning on updating that book? Or if someone else has a 6.1 MX OOP book in the works? I have heard that someone is writing a

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Ben Rogers
Personally I really hate the notion of chaining setter calls (but I can see way others may like it). I do find that much harder to read. But other chaining is great. Being able to chain the create and the init() together seems perfectly sound to me. As does any call which returns a

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jim Davis
-Original Message- From: Ben Rogers [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 29, 2004 10:04 AM To: CF-Talk Subject: RE: My Init() in my CFC...am I on the right track? I agree. I was only referring to setter methods (though I may not have been very clear about

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jochem van Dieten
Jim Davis wrote: As for returning this from a setter... I never thought about it, but I might start (mine all return void now). I may personally never use it, but if it doesn't affect performance it leaves to possibility open for others that might want to. I return this from pretty much

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jeff Small
Jim Davis wrote: As for returning this from a setter... I never thought about it, but I might start (mine all return void now). I may personally never use it, but if it doesn't affect performance it leaves to possibility open for others that might want to. I return this from pretty much

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Bosky, Dave
Don't break the chain of love. -Original Message- From: Jeff Small [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 29, 2004 11:40 AM To: CF-Talk Subject: Re: My Init() in my CFC...am I on the right track? Jim Davis wrote: As for returning this from a setter... I never thought

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Ben Rogers
So am I to understand correctly...that you can ONLY chain methods that return this? Or that if your init function returns an object then all methods can be chained? I'm reading all of this conversation as the former (the first one) meaning that if you WANT to be able to chain a method, that

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jochem van Dieten
Jeff Small wrote: So am I to understand correctly...that you can ONLY chain methods that return this? Yes. I'm reading all of this conversation as the former (the first one) meaning that if you WANT to be able to chain a method, that method needs to return this. Correct. Jochem

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Dave Watts
So am I to understand correctly...that you can ONLY chain methods that return this? Or that if your init function returns an object then all methods can be chained? I'm reading all of this conversation as the former (the first one) meaning that if you WANT to be able to chain a method, that

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jeff Small
You can only chain two methods if the first method returns an object containing the second method. If you want to chain two methods that belong to a single object, the first method needs to return the object containing that method (this). If you want to chain a third method, the second

RE: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Dave Watts
Good lord this is a lot of...ahem...stuff to remember... Fortunately, you don't really need to memorize it all as if it were a multiplication table. You just need to think about how objects, methods and properties work. For example, if you want to chain methods, you can see how things work

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Jeff Small
We already know that the CreateObject call returns an instance of foo, which contains a method bar so we can call that. To be able to call the baz method within the chain, we can see that bar needs to return the same object instance. I wish you could see me here at my desk with that

Re: My Init() in my CFC...am I on the right track?

2004-12-29 Thread Sean Corfield
On Wed, 29 Dec 2004 13:18:43 -0500, Jeff Small [EMAIL PROTECTED] wrote: Good lord this is a lot of...ahem...stuff to remember... Yeah, that's why it takes most folks years to become 'fluent' in OO design... Where's a good reference for ALL of this conceptual stuff? Not the syntax, or what you

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Sean Corfield
On Tue, 28 Dec 2004 11:39:22 -0500, Jeff Small [EMAIL PROTECTED] wrote: cfset init() Be wary of calling functions from the pseudo-constructor - if the CFC is accessed in any way, including the doc browser, it will execute this and call the function. In general I recommend *not* calling init()

RE: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Ian Skinner
Well I would say you maybe working a bit too hard. If that is all you want to do you can just do this. cfcomponent cfset variables.DSN = myDataSourceName cffunction ... This sets a variable that can be used by all functions. Now the limitation of this is that you can not

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Raymond Camden
A few comments here: *Typically i make my init function public so I can call it directly. This lets me do this in code: cfset mycfc = createObject(component,mycfc).init(arg1, arg2, arg3) You need to make your method do a cfreturn this for it to work right. *Your init function didn't have an

RE: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jim Davis
-Original Message- From: Jeff Small [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 11:39 AM To: CF-Talk Subject: My Init() in my CFC...am I on the right track? cfset init() cffunction name=init access=private output=false returntype=string displayname=Initializes

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Dave Carabetta
On Tue, 28 Dec 2004 11:39:22 -0500, Jeff Small [EMAIL PROTECTED] wrote: cfset init() cffunction name=init access=private output=false returntype=string displayname=Initializes my object and creates the datasource variable cfset variables.DSN = myDataSourceName cfreturn variables.DSN

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
Be wary of calling functions from the pseudo-constructor - if the CFC is accessed in any way, including the doc browser, it will execute this and call the function. In general I recommend *not* calling init() automatically in the CFC but requiring users of the CFC to call init() at

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
Not quite. 1) The access type on an init() function should be public, or you'll get an error saying the method doesn't exist when you invoke it in your calling code.. Makes *total* sense... 2) If you really want to make the value of variables.DSN public (to pass back to calling code),

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
A few comments here: *Typically i make my init function public so I can call it directly. This lets me do this in code: cfset mycfc = createObject(component,mycfc).init(arg1, arg2, arg3) You need to make your method do a cfreturn this for it to work right. *Your init function didn't have

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
Be wary of calling functions from the pseudo-constructor - if the CFC is accessed in any way, including the doc browser, it will execute this and call the function. In general I recommend *not* calling init() automatically in the CFC but requiring users of the CFC to call init() at

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jochem van Dieten
Jeff Small wrote: 5) One practice that has become a best practice of sorts is to return this from your init method so that you can method chain, as shown below. Granted, not everybody follows this practice, as it's more personal preference, but it's just what I'm used to now. I'm

RE: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jim Davis
-Original Message- From: Jeff Small [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 12:18 PM To: CF-Talk Subject: Re: My Init() in my CFC...am I on the right track? I'm struggling with this. I don't understand even from Seans's post what purpose it serves to return

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
From: Jochem van Dieten Jeff Small wrote: 5) One practice that has become a best practice of sorts is to return this from your init method so that you can method chain, as shown below. Granted, not everybody follows this practice, as it's more personal preference, but it's just what I'm used

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Matthew Drayer
cfset variables.DSN = myDataSourceName This might be a little off the best CFC practice topic, but why not create a second CFC to govern all contact with your database(s)? This way you don't have to worry about each CFC that lives in your world understanding database lingo and knowing

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jochem van Dieten
Jeff Small wrote: From: Jochem van Dieten Jeff Small wrote: I'm struggling with this. I don't understand even from Seans's post what purpose it serves to return this when you're using something like CFOBJECT or CreateObject() which creates an instance of an object anyway... Because that

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Dave Carabetta
On Tue, 28 Dec 2004 14:18:14 -0400, Matthew Drayer [EMAIL PROTECTED] wrote: cfset variables.DSN = myDataSourceName This might be a little off the best CFC practice topic, but why not create a second CFC to govern all contact with your database(s)? This way you don't have to worry

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
It should be noted that you'll get slight variations from people based on their preferences, but the code below generally covers best practices that I've seen. Here's the cleaned up CFC and the calling code is below it: cfcomponent output=false cffunction name=init access=public

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Dave Carabetta
Replies inline... On Tue, 28 Dec 2004 15:00:07 -0500, Jeff Small [EMAIL PROTECTED] wrote: It should be noted that you'll get slight variations from people based on their preferences, but the code below generally covers best practices that I've seen. Here's the cleaned up CFC and the calling

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jeff Small
Named: cfset setDSN(dsName:myDatasourceName) or cfset setDSN(dsName=myDatasourceName) Aha! This I got immediately. I understand it all now and once we were both clear on what I was doing, it makes perfect sense both in what you were doing, and syntactically what you were writing. I've seen

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Sean Corfield
On Tue, 28 Dec 2004 12:08:54 -0500, Jeff Small [EMAIL PROTECTED] wrote: Okay, this makes sense. I'm reading about 4 different sources for how to build CFCs correctly I hope that includes both of the Macromedia Web Team docs :) http:/livedocs.macromedia.com/wtg/public/ Note that even tho' the

RE: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Ben Rogers
This allows you to chain method calls, as others have noted, and will probably help get you more into the habit of using cfset and method calls (rather than cfinvoke which I also advise against). Just to be clear, are you advising people to chain method calls? Personally, I'm not crazy about

RE: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Jim Davis
-Original Message- From: Ben Rogers [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 28, 2004 4:35 PM To: CF-Talk Subject: RE: My Init() in my CFC...am I on the right track? This allows you to chain method calls, as others have noted, and will probably help get you more

Re: My Init() in my CFC...am I on the right track?

2004-12-28 Thread Joe Rinehart
If parameters are not needed, I would feel the init() method is not needed. But I'm sure that is debatable. Hey Ian, Not trying to debate, just giving my point of view: I'd use the init() method regardless of the need for parameters. This way, if parameters need to be added, the external