|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
ColdFusion & Polymorphism use
I have an animal object with a method call makeSound().Dan O'Keefe 06/29/12 06:01 P Since oCat extends feline, you'd be looking for super.makeSound().Matt Quackenbush 06/29/12 06:09 P Thanks Matt,Dan O'Keefe 07/02/12 09:22 A > That's true, but super is limited to only one level I believe. How about ifDave Watts 07/02/12 09:37 A Dan-Cameron Childress 07/02/12 10:57 A Thanks Cameron, that makes sense.Dan O'Keefe 07/02/12 04:07 P 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 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 ----- 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 ----- > 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. 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> 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 -----
|
June 18, 2013
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||