> Correct me if I'm wrong, but based on my initial reading of CFCs on the
> web, it seems like there are three ways of setting up constructor data:
> Is there a preferred method?

The difference between code at the top of your component outside any methods 
(which gets ran on the component's creation) and a pseduo-constructor method 
like init() that you call yourself upon the creation of the component is 
that you can pass arguments into the init method.  If your only 
initialization is something really basic like <cfset variables.instance = 
structnew()> then the init isn't really doing anything for you.  If you want 
to pass data into the component upon its creation to aid in its 
initilization or population, you will want to use init()

myPerson = 
createobject("component","person").init(firstName="Brad",lastName="Wood");

> Maybe I'm not understanding the goal of the init() method and to whom
> that data is supposed to be made available.  Is it for the purpose of
> providing data to the newly created object or is it to initialize data
> for the other methods in the class.. or both?

It can be for whatever you want.  :)  Both of those would be fine.

>>    - We can now call super.[method] to invoke methods on a superclass.
>
> seems simple enough.  Don't have any near-future plans to call super
> methods just yet until I get my head wrapped around this :)

You won't really until you start uning inheritance and want augment 
functionality provided through a base class.  The most often place I use 
super. is in my init methods. If you are extending a class with an init 
method, you need to make sure the child init does a super.init() or the base 
class's init() won't be called.

> What's the difference between private and protected?

Private is only available to methods in that component.  Protected is 
available to any component in the same folder.  In my opinion this assumes 
you are using the package set up where your components are in folders like
/CFC/business/person/personBean.cfc
/CFC/business/person/personService.cfc
/CFC/business/person/personFoo.cfc

Any of those components could access each other's protected methods. 
Someone correct me if I am wrong, but I do not believe ColdFusion provides a 
way to mark a variable as protected.

~Brad 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:319031
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to