I see plenty of applications with init() declaractions that help create the variables scope or dependent objects into the variables scope to assist the CFC.
The return type of the CFC can be void or it can return a copy of the object. It depends on what you are trying to instantiate.
You can have return types that are based upon your programming style. If you want the CFC to be very simple and just returns processed values, then returntypes of data structures are fine.
If you want to return a copy of the object into the instantiation, you want to return the object. By returning the object, the calling source can use the methods and data that is currently stored in your CFC.
I apologize for using the phrase "ite depends," but CF does provide you with a lot of options that suits the programming styles of many.
What is bad practice for some may be good practice for others. The goal here is to be objective and try out ways that suit your style as you develop your own style.
Teddy
On 9/4/06, Paul Hastings <[EMAIL PROTECTED]> wrote:
Phillip Senn wrote:
> But the resourceBundle.cfc written by Paul Hastings has got me confused.
w/input from ray. i guess it's been quite a while since anybody poked around
inside that thing.
> First, the "init" function is called "loadResourceBundle", and its
> returntype="void".
that's not really an init function. the "init" bits are the pseudo init bits at
the top of the file (and this is now "known" to be a bad practice).
> Second, the getResourceBundle method has returntype="struct", and it's
> last statement is:
>
> <cfreturn resourceBundle>
>
> Why doesn't he make the returntype components.resourceBundle and
>
> <cfreturn this>
because that was all that CFC was meant to do, read an rb file into a struct &
return it to the blog. since it was added recently i can recall that the
messageFormat method (if that's in the version you have) was added at the
request of the asFusion folks for *their* blog & i don't want to support a
barnyard of different versions. i forget why the other methods were added.
i haven't bothered tuning this thing up as it's used in too many places so stuff
might break or at least will have to be redone in the calling app. also it's not
our "bread & butter" rb functionality--that's in javaRB & rbJava CFCs which
probably follow more "modern" CFC practices.
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm
CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
--
<cf_payne />
Blog: http://cfpayne.wordpress.com/
Atlanta CFUG: http://www.acfug.org
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm
CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com
An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
