Brad, I love the microwave analogy.

Phillip, CFCs as a fancy include tends to be the first step on your way to
really understanding components and objects. I've been with a few groups who
have gone (and taken me) through the course. The evolution is like this:

---------------------------
CFC as a function utility library. Functions are a small piece of reusable
code, putting them together makes sense.

Put that util.cfc in the application scope, seems to make it faster. (now
it's a "singleton")

CFC as a place to put your queries. Moves them out of separate files or the
top of your cfm pages. Some get stuck here because this is the least
reusable stage. This is not OO and makes working with CFCs very
uncomfortable.

CFC as the action back-end (the "model") to an area of your application.
Similar to the above, but may have more processing, and some functions
without any queries.

CFC as a black-box to a specific concept in your application. Finally a real
object with properties and methods. Now, finally, you have an object that
can be reused. This step usually comes out of need for something that has to
be used in multiple apps or laziness (in a good way), not wanting to re-type
boilerplate stuff like a user/login system.

And finally, eventually, an actual model, with more objects and some actual
layers of objects. Here, you will recognize larger pieces of your
application that can be reused, not just single CFCs.
---------------------------

This is not to say that everybody will do this, everyone's experiences are
different, but it's just a pattern I've seen.

nathan strutz
[Blog and Family @ http://www.dopefly.com/]
[AZCFUG Manager @ http://www.azcfug.org/]
[Twitter @nathanstrutz]


On Tue, Sep 8, 2009 at 10:47 AM, <[email protected]> wrote:

>
> I'd sure hate to write a SOAP webservice in a .cfm file.
>
> Also, cfm files don't give you objects that can be passed around,
> provide encapsulation of data, and support code re-use via inheritance
> and method overriding.  I mean, you can do anything you want in cfm
> files, but there are some things that are just way cleaner and easier in
> a component if you want to drink the koolaid and change your paradigm.
> CFCs can be used as glorified include files with no ill side affects,
> but if that is all you are doing with them it's kind of like starting
> your microwave on fire to cook your supper over it. :)
> ~Brad
>
> -------- Original Message --------
>  Subject: CFC's.. Why use them?
>  From: Phillip Vector <[email protected]>
>  Date: Tue, September 08, 2009 9:39 am
>  To: cf-talk <[email protected]>
>
>
>  Besides the code being reusable, is there a specific reason why I
>  should use a CFC rather then a CFM file?
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326098
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