> to call my init function inside my CFC, do I make it
> "private" or "package" and why would I choose one over the other?
>
> <cfcomponent name="mycomponent">
> <cfset init()>
>
> <cffunction name="init" access="private/package">
> <cfset variables.myDSN = "MyDataSourceName"> </cffunction>
>
> ...
>
> </cfcomponent>
If the only place from which you wanted to invoke your init function was
within the CFC that contains the function, use private. If you want to be
able to invoke that function from within other CFCs in the same directory,
use "package".
That said, you may want init to be public, since the use of public functions
called "init" is a common workaround for the lack of proper constructor
functions within CFCs. These public functions typically accept arguments
that can be passed from the page which creates the CFC instance, and this
can be done within the same line of code as that which creates the instance
using method chaining.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]