Yeah Bobby and Rick, that was just stupid of me wasn't it? :)
Each of these were originally placed right before I was going to use the
object in their various pages and then I bulk moved them up to
Application.cfm without removing the cfif tests.
That said, let me remove the offending code so we can get back to the
central question.
(in application.cfm)
<cfset request.dsn = "mydatabase" />
<cfset request.inventory = createObject("component",
"cfcs.inventory").init(request.dsn) />
<cfset request.classes = createObject("component",
"cfcs.classes").init(request.dsn) />
...
/application.cfm
Each instantiation is calling a simple init() method within the class such as
this one within inventory.cfc:
<cfcomponent hint="Inventory Object">
<cfset variables.dsn = "" />
<cfset variables.inventory = "" />
<cffunction name="init" access="public" returnType="inventory" output="false"
hint="I instantiate inventory">
<cfargument name="dsn" type="string" required="yes" />
<!--- initiate value(s) --->
<cfset variables.dsn = arguments.dsn />
<cfset variables.inventory = "none" />
<cfreturn this />
</cffunction>
(there are more methods within this cfc but I'm leaving them out to make this
easier to read.)
</cfcomponent>
My question is that since these objects are dynamic data (change often),
is it OK to just instantiate the objects even if I may not call one of
them an that particular page request? Is instantiating an object that
simply calls an init() method (as seen above) any more costly than say a
<cfparam name="blah" default="">? Or, am I just going down a path I
probably shouldn't and just test EVERY single time if I need to
instantiate an object when I want to call a method of that object?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies
around the world in government. Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288937
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4