Only the functions you explicitly call are executed. Creating an object is
copying and instance of that component to memory. This is useful for
maintaining the object's state. When I write CFCs that are actually
intended for use as objects and aren't simply collections of functions, I
create an init() function and call that when creating an object. Using
CreateObject() instead of <cfobject> makes it easy to call the init in one
line. To extend your example, I'd do it this way:
<cfset reviews = CreateObject("component",
"#application.cfcpath#reviews").init()>
<cfset qGetTopTenTitle = reviews.getTopTenTitle(url.Campus)>
On Thu, Apr 24, 2008 at 3:25 PM, John Ahlen <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I've gotten into the habit of beginning a page by creating an object:
>
> <cfobject component="#application.cfcpath#reviews" name="reviews">
>
> Below that, I use any number of cfinvokes thusly:
> <cfinvoke component="#reviews#"
> method="getTopTenTitle"
> campus = "#URL.Campus#"
> returnvariable="qGetTopTenTitle">
>
> In the component I'll have functions that are not called by the page. They
> are used by other pages. When I turn a component into an object am I
> needlessly calling all the functions inside that component and is this not a
> good idea?
>
> Thanks in advance,
>
> John
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304204
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4