Hey guys,

I'm working on designing a new project, and in thinking through some
of it I came across this.  Sorry if this is a newbie question, but
just thought I would get some reactions.

When typing objects in cf, the typing depends on how the objects were
created, not on the actual path to the objects (physical path).

For instance, say I create an object called foo in the {application
root}/com/ directory, so {root}/com/foo.cfc

and I give it an init call like so:

<cffunction name="init" access="public" returntype="com.foo">

<cfreturn This />
</cffunction>

Okay, so now I go to a new page somewhere and I create an obect out of
the component like so:

<cfset variables.foo = createObject("component","com.foo").init() />

All good right?  The return type says com.foo, the create object uses
com.foo and everything works fine.

Okay, now lets say I make a new mapping in cf to the com directory,
called com_mapping.

So now I try to create an object out of the cfc using the following code:

<cfset variables.fooWithMapping =
createObject("component","com_mapping.foo").init() />

An error is thrown, because the path to the cfc that you are using the
create the object is not exactly the same as the type specified in the
returntype of the init...  Since foo is still accessible using
com.foo, and that is the actual path to the cfc, shouldn't it still
work?

If you change it to returntype="any" both calls work, but you loose
that type checking.

Now,  I know all about duck typing and the possible performance
concerns of typing, but at the end of the day, the typing was intended
to be used like this, and this seems a little illogical?  I don't have
a java background and don't know if this issue would translate well to
the java world, but I would be interested in seeing if there was some
sort of correlation.

For an example of why this matters, imagine that you had multiple
releases of the same application, myApp v1 and myApp v2 that you
wanted to have both available at the same time on the same server.  So
for example:

{domain}/myApp/v1/ and {domain}/myhApp/v2/

The same code base except v2 is just a newer copy with some new
features right?  Well lets say the application uses an external
resources such as some sort of framework.  Lets say for example its
transfer.  So v1 of the application uses v0.5 of transfer, and v2 of
the application uses v0.6 of transfer.  If transfer uses typing in its
objects (I really have no idea, ive never used transfer, this is just
an example) then you can't just use a new mapping to get to the new
version in v2 from v1.

Sorry for the long email, just curious if anyone has ran into this and
possible workarounds... because if the framework uses typing in its
objects (this would also apply to inheritance of objects I would
think) then its not really an option to go through and change return
types to "any" everywhere...

--
Ryan Guill
A Deep Blue
[EMAIL PROTECTED]
www.ryanguill.com
(270) 217.2399
got google talk?  Chat me at [EMAIL PROTECTED]

www.ryanguill.com/
A Deep Blue Blog: www.ryanguill.com/blog/


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/cfcdev@cfczone.org

Reply via email to