E-Mail:
Get our new Windows 7 eBook (PDF) for $7 with 70+ Tips. Download Now!

CFCs: OO is more than function libraries!!!

  • No Related Post

So, just how seriously do you take your CFCs? I bet not half as seriously as this guy! In a recent article from clearsoftware.net, Joe Rinehart explains to his readers that there is a lot more to CFCs than a simple library of functions.

From a list: “They are just an array of functions you call from a separate file.” Whoa! CFCs are a lot more than a library of functions - they open ColdFusion to object-oriented thought.

CFCs are to CF what a Class is to Java, C++, C#, VB.NET, or [insert OOP language here].

strong>Difference between a CFC and a function library, distilled:

A library of functions can be included via CFInclude. The functions all live in a seperate .CFM (or any other extension…) file, but are all independent of each other. The “array of functions” that a CFC contains, however, can share data between each other. The .CFC file has its own variables scope that’s seperate from the calling page’s, much like a custom tag.

Because a CFC can “hold” data, it’s less of an included function library, and more like a “super structure” - wheras a normal CF struct can hold data, a CFC can both hold data, and use functions to do things to that data. While a normal CF struct called “person” would probably have a member known as “person.firstname”, a CFC’s data should be kept private, and exposed through functions like “person.getFirstname()”.

What Do You Think?

 
35 queries / 0.250 seconds.