FWIW, another way to use this is demonstrated in an Iterator.cfc I built for
my CFC class to show this very thing off (attached) -- where I take private
methods and make them public, so the end developer can use the same methods
(next(), previous()) for several CF data types (query, struct, list, or
array)

The operative lines of code in init() are:

this.next = variables["getNext" & instance.type];
this.previous = variables["getPrevious" & instance.type];





> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Nat Papovich
> Sent: Tuesday, March 16, 2004 6:57 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] RFC, CFC Best Practices
>
>
> By golly Ben, that does work (at least in my preliminary tests).
> How interesting. If you were anal about making sure init() was
> called, and you had other lazy developers who couldn't be trusted
> to do it right, you could make CFCs like this.
>
> NAT
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Ben Curtis
> > Sent: Tuesday, March 16, 2004 12:45 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [CFCDev] RFC, CFC Best Practices
> >
> >
> >
> > > Speaking of init...
> > > I don't want to add checks to all my methods to
> > > make sure Init() was called.
> >
> > I've been toying with the idea that all methods are private
> > *except* init(), which is public. When init() gets called
> > properly and everything works right, then the last thing it
> > does is "publicize" the methods that should be public:
> >
> >    This.someMethod = Variables.someMethod;
> >    This.someOtherMethod = Variables.someOtherMethod;
> >
> > ...and so on, and then "privatize" the init() method itself:
> >
> >    Variables.init = This.init;
> >    StructDelete(This, "init");
> >
> > ...so it can't be called twice.
> >
> > I haven't tried it yet. Don't have time no, but I figured I
> > could put the idea out there and let y'all find out what's
> > wrong with it.
> >
> > --
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>

Attachment: iterator.cfc
Description: Binary data

Attachment: iterator.cfm
Description: Binary data

Reply via email to