It took me a while, too. Finally, one day the light bulb lit up: the big
deal about polymorphism is that is encapsulates variation. It allows for
adding and eliminating the concrete subtypes of an abstract class
without changing the classes that use them.  

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
> Of Nando
> Sent: Wednesday, October 27, 2004 9:21 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] calling a supertype from outside the subtype
> 
> Ok, and what if the "Vehicle Registration Authority" needs to know
what
> type
> of vehicle is at a particular location? To continue the analogy, how i
> have
> it is that "The VRA" asks Vehicle for that information. If Vehicle has
a
> vehicleType property, is this prima facia evidence that the
relationship
> between Vehicle and Car isn't inheritance?
> 
> I've had a hard time getting my head around polymorphism in practice -
so
> far.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Roland Collins
> Sent: Thursday, October 28, 2004 2:31 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] calling a supertype from outside the subtype
> 
> 
> I think you may be modeling the relationship wrong.  To use your
Vehicle
> example...
> 
> Vehicle would be a Base Class - it wouldn't have a "vehicle type"
> property.
> Instead, you would have subclasses extend it.  The hierarchy could
look
> like
> this:
> 
> Vehicle
> -----.Location
> -----.NumberOfWheels
> 
> MotorCycle Extends Vehicle
> -----.DriveType
> 
> Truck Extends Vehicle
> -----.BedLength
> 
> Car Extends Vehicle
> -----.SomeSillyProperty
> 
> By doing this, instances MotorCycle, Truck, and Car all have access to
all
> of Vehicle's methods without using the super keyword.  If you're
> overriding
> a method in the derived class, then that is an implementation decision
and
> an interface that should not be circumvented by your end user.  If
they
> really need to access the overridden method in the Base Class, they
should
> cast the derived class as the base type and then call the method.
> 
> My .02
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
> Of Nando
> Sent: Wednesday, October 27, 2004 8:08 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] calling a supertype from outside the subtype
> 
> Ok, so here's the situation. Perhaps my example wasn't the best.
> 
> I'm passing the subtype into the supertype's DAO. Here's the relevant
> snippet to give a sense of it.
> 
> <cfqueryparam cfsqltype="cf_sql_integer"
> value="#variables.thisContentObj.getSuperIdPage()#" />,
> <cfqueryparam cfsqltype="cf_sql_varchar"
> value="#trim(variables.thisContentObj.getStrContentType())#" />,
> <cfqueryparam cfsqltype="cf_sql_integer"
> value="#variables.thisContentObj.getIntPosition()#" />,
> <cfqueryparam cfsqltype="cf_sql_varchar"
> value="#variables.thisContentObj.getSuperStrLang()#" />
> 
> There were 2 values from the supertype that i needed - to get this
working
> for the moment i added getters - getSuperIdPage() and
getSuperStrLang() -
> getStrContentType() and getIntPosition() are both in the supertype
only -
> they work fine as is.
> 
> As it turns out, I could as well get these values from the subType, as
> they
> are shared, duplicated actually for convenience - i just got a little
> fixed
> on the idea that they should come from the supertype.
> 
> So the design flaw may be more in my database structure, as i'm
> duplicating
> a few values rather than running a lot of joins in my gateways for
> performance sake - or it may be in the way i'm passing the subtype
into
> the
> supertype's DAO - but in context this seems to make a lot of sense to
me.
> Or
> it may just be my silly idea that the duplicated data should come from
the
> supertype.
> 
> Or it may be that i should be modelling this relationship using
> composition.
> The "supertype" handles 2 things, it defines a position (on the
webpage)
> for
> the subtype - and it defines exactly "the type" for the rest of the
> application, as if Vehicle would have a vehicleType attribute that
could
> be
> Car or Motorcycle or Truck, and it also had a location attribute (call
it
> a
> garage or a parking place) to allow any type of vehicle to park there.
> 
> In any case, the only reason i'm drawing this issue out is to see how
> people
> approach this. Again, passing the subtype into the supertype's DAO
seem
> like
> a good move, but now i'm not so sure.
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Nando
> Sent: Wednesday, October 27, 2004 10:52 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] calling a supertype from outside the subtype
> 
> 
> Really? Well lemme step back and rethink where i'm at then in this
before
> i
> say anything more then. :)
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Barney Boisvert
> Sent: Wednesday, October 27, 2004 10:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [CFCDev] calling a supertype from outside the subtype
> 
> 
> You should never want to do this.  If you want the behaviour of the
> superclass, you should be using an instance of the superclass
> directly. Your workarounds would probably work, but the idea itself
> blatantly eliminates all the benefits of polymorphism.  I'd be very
> careful about ever using that type of setup without careful
> consideration of the way the relevant components are related.
> 
> cheers,
> barneyb
> 
> On Wed, 27 Oct 2004 21:11:19 +0200, Nando <[EMAIL PROTECTED]>
wrote:
> >
> > I don't expect there to be a way to do this, but i just thought i'd
> check.
> >
> > From within a subtype, you can of course use the super keyword to
call a
> > method of the same name in the supertype.
> >
> > super.myMethod()
> >
> > Is there a way to do this from outside the subtype? For example
> >
> > <cfset mySubType = createObject('component','SubType').init() />
> > <cfset mySubType.super.myMethod() />
> >
> > This doesn't work, i'm just trying to express the idea clearly.
> >
> > My 2 workarounds if there is no direct way to do this would be
either to
> > create a function in the subtype to return the value from the
supertype,
> or
> > to add another getter of a different name in the supertype.
> >
> > ???
> >
> --
> Barney Boisvert
> [EMAIL PROTECTED]
> 360.319.6145
> http://www.barneyb.com/blog/
> 
> I currently have 0 GMail invites for the taking
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> 
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at www.mail-
> archive.com/[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

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

Reply via email to