Brian Kotek wrote:
>    - All function-local variables must be declared with the "var" keyword

Yeah, I've read extensively that it's very important to do this with 
every variable declared inside a function.  Btw, does this also mean 
that query names need to be var-scoped as well?  i.e.

<cfset var GetParks = 1>

<cfquery name="GetParks" datasource="dsn">
SELECT name FROM table
</cfquery>


>    - The VARIABLES scope within a CFC represents private data

That I understand.


>    - The VARIABLES scope should be used instead of the THIS scope for object
>    properties to enforce encapsulation

Yeah, I noticed that the book uses the "this" scope.  I also noticed 
that the book outputs data from CFCs which I've read is a nono in 
regards to best practices.  I'm assuming the correct method to retrieve 
the data stored in the properties is by calling the class' methods, correct?


>    - An init() method is the de-facto constructor method

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: 
putting any cf tags or functions in the constructor area, putting a 
<cfset init()> statement in the constructor area that calls the init() 
method, or calling the init() method during the object instantiation. 
Is there a preferred method?

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?  If anyone has any pages 
describing constructors and their uses (even if it's in another 
language), that would be helpful.


>    - 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 :)


> If you can keep those rules in your head as you read (which I realize may be
> difficult), the majority of the concepts are still valid (composition,
> polymorphism, etc,).

I think knowing about the "this" scope best practices is helpful.  Was 
the variables and var scope not available at the time


> (Yes, I know the variables scope behaves like protected, not private. Yes, I
> know some people prefer keeping properties in the THIS scope. I kept the
> list simple because it's already going to be hard enough for him to keep
> track of it and there's no need to dive into minutiae at this point.)

I like the idea of keeping the properties local to the CFC otherwise you 
break the benefits of encapsulation (or at least, I see it as a benefit).

What's the difference between private and protected?

thanks!
Mike




> 
> Regards,
> 
> Brian
> 
> 
> On Sat, Feb 7, 2009 at 8:06 PM, Mike Soultanian <[email protected]> wrote:
> 
>> Hey Everyone,
>> I just purchased Discovering CFCs by Hal Helms and I already know that
>> the book is somewhat out of date (Hal told me so).  However, what I
>> really wanted was an introduction to OO and CFCs and this seemed like a
>> descent starting point.
>>
>> I am starting to get further into the book (on page 50 right now) and
>> I'm starting to see more CFC code.  What I wanted to find out is what
>> stuff is out of date, if it's possible to generalize.  Are there any
>> sites out there that outline the changes since MX?  Any suggestions
>> would be much appreciated!
>>
>> Thanks,
>> Mike
>>
>>
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:319028
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