What if you have a subclass of com.truck named com.compacttruck and
need to know if that class can tow a boat?  You'll need to ascend the
object hierarchy and check every level.  Check my UDF from the first
post I made in this thread for an implementation.

Really, this problem pretty much requires interfaces to solve
elegantly, but we don't have them with CFCs.  The vibe I get is that
it's never going to change, which is unfortunate, but such is life. 
You could use synthesized interfaces (an 'implements' attribute in the
CFCOMPONENT tag) to do typechecking, but you'd obviously not get any
of the compile-time benefits.

cheers,
barneyb

On Apr 6, 2005 1:25 PM, Roland Collins <[EMAIL PROTECTED]> wrote:
> > Instead of asking the car what type of car it is, why don't you just
> >ask it whether it can tow boats?
> >
> ><cfif myCar.canTowBoats()>
> 
> The only problem with this is flexibility.  For each role that you then want
> your vehicles to maintain, you have to add a property.
> 
> As far as runtime determination of class name - that's easy!  No need to
> store it anywhere:
> 
> <cfif GetMetaData(myVehicle).Name is "com.truck">
>         Tow my boat!
> </cfif>

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]


Reply via email to