Now for legibility reasons, having the psuedo constructors placed in between methods may make it hard to read and debug. Placement at the top would be preferred to symbolize that they are executed first. Application.cfc creates settings outside of the core methods. It really comes down to do the usage of the psuedo constructors. Creating default variable holders like a cfparam usage or creating static variables seems acceptable in most implementation I have seen. Init methods provide control and flexibility.
I think we are academic at this point from Phil's original question.
Teddy
On 9/4/06, Nando <[EMAIL PROTECTED]
> wrote:
Yep. The area inside a cfcomponent tag and outside of any function is known as the "pseudo constructor", and that code is run once when a CFC is instantiated. I don't like writing code like that, but i don't mind it so much if someone uses this to construct their CFC, as long as they document it well, AND put all the constructor code at the TOP of the CFC.
You can put it anywhere, between 2 of the functions, some at the top, some in the middle, some at the bottom. That would be bad practice to me.
I remember, way back when in the early days of CFC's, someone saying something to the effect of "the problem with the pseudo constructor, the way Macromedia has implemented it, is that you can have code anywhere inside the CFC but outside any function and it will run on instantiation. Even a misplaced copy/paste will run." And everyone on the list went "yuck ... bad practice".
Seems like you misinterpreted Paul's phrase ' "init" bits ' to mean they were inside an init function? Threw me a little too at first.
Teddy Payne wrote:Are we talking about declaring variables into the to "this" scope or the "variables" scope outside of a method?
Teddy
On 9/4/06, Jim <[EMAIL PROTECTED]> wrote:>the "init" bits are the pseudo init bits at the top of the file (and
this is now "known" to be a bad practice).
I think he's referring to code at the top of a cfc which is outside of
any cffunction tag. not an init method.
>assist Phillip into thinking there is a not "right" solution for
everything
pseudo inits cause you to lose runtime control over the init. IMHO, this
is a wrong solution, for everything! :)
Teddy Payne wrote:
> If I did I apologize, but the goal of my email was identify that style
> of CFC invocation is on a case by case need and usage.
>
> Init can work fine for one method or not so hot for another method.
>
> Your statement was not my concern, but rather to assist Phillip into
> thinking there is a not "right" solution for everything.
>
> He like most developers will try and attempt different ways to
> approach a problem before choosing a method that is right for him at
> that given time.
>
> I am not rebuking your statements by any means.
>
> Teddy
>
> On 9/4/06, *Paul Hastings* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Teddy Payne wrote:
> > I am not sure having an init() method to CFC is a bad practice.
>
> you seem to have misread my email.
>
>
>
>
> 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 <http://www.katapultmedia.com>
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
> <http://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]
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.11.6/430 - Release Date: 28/08/2006
>
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]
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]
