House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

ColdFusion & Polymorphism use

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Thanks Matt,
Dan O'Keefe
07/02/12 09:22 A
Dan-
Cameron Childress
07/02/12 10:57 A
Thanks Cameron, that makes sense.
Dan O'Keefe
07/02/12 04:07 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan O'Keefe
06/29/2012 06:01 PM

I have an animal object with a method call makeSound(). Then I have a feline object that extends animal with a method called makeSound(). Then I have an object named cat that extends feline with a method called makeSound(). If I instantiate the cat object and call it oCat, I can call oCat.makeSound() and get the cat sound. QUESTION IS, how do I call the makeSound() method in the feline object via the oCat handle? I am told it is possible but I have not been able to find out exactly how. I did read you need to pass a type reference to it but not sure what that means. Would it be oCat.makeSound(feline) ?? -------------- Dan O'Keefe

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Quackenbush
06/29/2012 06:09 PM

Since oCat extends feline, you'd be looking for super.makeSound(). // oCat function makeSound() {     super.makeSound(); } HTH On Fri, Jun 29, 2012 at 7:49 AM, Dan O'Keefe <dan.okeefe@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan O'Keefe
07/02/2012 09:22 AM

Thanks Matt, That's true, but super is limited to only one level I believe. How about if I wanted to execute the method in the animal object? Dan On Fri, Jun 29, 2012 at 3:08 PM, Matt Quackenbush <quackfuzed@gmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
07/02/2012 09:37 AM

> That's true, but super is limited to only one level I believe. How about if > I wanted to execute the method in the animal object? Presumably, the feline object already extends the makeSound method of the animal object, right? Why wouldn't you just have the cat object extend the makeSound method of the feline object? Why would you want to skip a generation, so to speak? That seems like it would be poor design. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Cameron Childress
07/02/2012 10:57 AM

Dan- As Dave pointed out, I'd typically make a standard assumption in most design that each subtype would automatically call super on extended methods / interfaces. This would mean that each level would contain the super.makeSound() to chain them all together as you go up the path of inheritance. -Cameron On Mon, Jul 2, 2012 at 9:22 AM, Dan O'Keefe <dan.okeefe@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Cameron Childress -- p:   678.637.5072 im: cameroncf facebook <http://www.facebook.com/cameroncf>; | twitter<http://twitter.com/cameronc>; | google+ <https://profiles.google.com/u/0/117829379451708140985>;

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan O'Keefe
07/02/2012 04:07 PM

Thanks Cameron, that makes sense. I agree with Dave's position and guess I should have pointed out I do not have a valid use case for this, but only trying to sort through the limitations of a question posed to me. Thanks, Dan On Mon, Jul 2, 2012 at 7:56 AM, Cameron Childress <cameronc@gmail.com>wrote: ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

June 18, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
             1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30             

Designer, Developer and mobile workflow conference