Question about Discovering CFCs

2009-02-07 Thread Mike Soultanian

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:319026
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Question about Discovering CFCs

2009-02-07 Thread Brian Kotek

Most of the general ideas are still applicable. The biggest differences that
I can think of are:

   - All function-local variables must be declared with the var keyword
   - The VARIABLES scope within a CFC represents private data
   - The VARIABLES scope should be used instead of the THIS scope for object
   properties to enforce encapsulation
   - An init() method is the de-facto constructor method
   - We can now call super.[method] to invoke methods on a superclass.

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,).

(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.)

Regards,

Brian


On Sat, Feb 7, 2009 at 8:06 PM, Mike Soultanian msoul...@csulb.edu 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:319027
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Question about Discovering CFCs

2009-02-07 Thread Mike Soultanian

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 msoul...@csulb.edu 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


Re: Question about Discovering CFCs

2009-02-07 Thread Paul Kukiel

Mike,

Just this week Josh Adams gave a really good presentation on scopes.   
Have a watch of this I am sure it will answer many of your questions.

https://admin.na3.acrobat.com/_a204547676/p74013218/

Paul.


On 07/02/2009, at 10:12 PM, Mike Soultanian wrote:


 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  
 msoul...@csulb.edu 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:319029
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Question about Discovering CFCs

2009-02-07 Thread James Holmes

It's worth adding that CF8 now supports interfaces via the cfinterface tag:

http://cfquickdocs.com/cf8/?getDoc=cfinterface

mxAjax / CFAjax docs and other useful articles:
http://www.bifrost.com.au/blog/


2009/2/8 Brian Kotek brian...@gmail.com:

 Most of the general ideas are still applicable. The biggest differences that
 I can think of are:

   - All function-local variables must be declared with the var keyword
   - The VARIABLES scope within a CFC represents private data
   - The VARIABLES scope should be used instead of the THIS scope for object
   properties to enforce encapsulation
   - An init() method is the de-facto constructor method
   - We can now call super.[method] to invoke methods on a superclass.

~|
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:319030
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Question about Discovering CFCs

2009-02-07 Thread Brad Wood

 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


Re: Question about Discovering CFCs

2009-02-07 Thread Brian Kotek

Brad, you're confusing protected with package. Package allows objects in the
same package (folder) to access a variable. Protected means the variable is
accessible by subclasses.

On Sat, Feb 7, 2009 at 10:43 PM, Brad Wood b...@bradwood.com wrote:


 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:319032
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Question about Discovering CFCs

2009-02-07 Thread Brian Kotek

On Sat, Feb 7, 2009 at 10:12 PM, Mike Soultanian msoul...@csulb.edu wrote:


 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?


Right, when the book was written there was no private variables scope
available within a CFC, except via a hack (which the book will show and
which you can ignore).

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?


Yes, as Brad mentioned, it is the common practice to chain an init() call
when you create the object. It does mean that your init() method needs to
return this:

cffunction name=init
cfreturn this /
/cffunction


 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.


http://en.wikipedia.org/wiki/Constructor_(computer_science)

A constructor in most languages is a block of code that is automatically
executed when the object is created. So it is a place to set up the object
and put it into a usable state. Since we don't have constructors in
ColdFusion, the init() method has to be explicitly called.


~|
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:319033
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Question about Discovering CFCs

2009-02-07 Thread Dave Watts

 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.

Someone correct me if I'm wrong too, but I don't think you can mark a
function as protected. The four ACCESS attributes in CF8 are public,
private, package and remote, and as Brian pointed out, you've
described package.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~|
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:319034
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Question about Discovering CFCs

2009-02-07 Thread Brad Wood

 Brad, you're confusing protected with package. Package allows objects in 
 the
 same package (folder) to access a variable. Protected means the variable 
 is
 accessible by subclasses.

Oops, you're right Brian.  For some reason I'm confusing the two tonight. 
Thanks for the correction.
I've been painting tonight, so I'll blame it on the fumes :)

~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:319035
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4