I think Mike nailed it.

People who say that CFC should not create html must also think that no
class in java can create output, and that clearly won't fly (since java
has nothing but classes).  CFCs should have a single, clear purpose. If
that purpose includes creating html than so be it.  The OO property of
encapsulation key; define your interfaces (the public functions)
carefully and you'll be in a good place.  These says I create Custom
Tags less and less often.  They are still useful, of course, and
sometimes they are perfect for the problem at hand, but CFCs are so
flexible and powerful that I use them for may tasks that I would had
done with Custom Tags before.

-----Original Message-----
From: Michael Dinowitz [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 08, 2007 6:59 AM
To: CF-Talk
Subject: Re: bad cfc practice but why?

This is not a rule of CFCs, just a 'suggestion' from some of the people
using them. There logic is to separate the logic of an application from
its presentation. This allows for easy change of the presentation
without touching the logic. The argument is logical, but not necessarily
the rule. 

I ignore it when logic dictates that it should be ignored. For example,
I have a single comment component that has all of the code and display
to handle a comment. I see no reason to have the display in another
template and if someone else was using the component and wanted a
different display, they could just inherit my component and change the
display method. But that might be considered bad OOP, which is an
argument I also ignore when logic dictates.

If you find that you have a reason to include display in the same
component as logic, pay particular attention to the output attribute and
what it does. 

> Thing is I know I'm not supposed to put any presentation stuff in
them. 
> But say for example I had a poll cfc. I can run all of the actions 
> through the CFC fine, but why not add some optional basic html (i.e.
> form & results) so that if wanted, the whole poll could be 
> encapsulated within the one file and in theory could be added to any 
> site with just a couple of lines of code. If the basic form & results 
> didn't suit I could then go for a tailored option for the sites that 
> needed it but all would still be based on the one cfc.
> 
> So would this a bad thing and why?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272012
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