"seems a bit muddled... you're always going to get methods of the current class (overridden or inherited) if you use variables.method(), this.method() or method() to call the method. Super.method() allows you to invoke a method of the parent class."
You're absolutely right. It was my misunderstanding of a book I read describing the functionality in CF. However, rather than test it through a simple test case because it sounded weird to me, I accepted it. I was wrong. I was actually wrong in more ways than one... My interpretation of what the book was saying was wrong. It has nothing to do with calling an overridden method in a child class - it's about calling functions in the child from the parent even if the function isn't defined in the parent. I've since discovered (through testing that "this" isn't required at all). This new understanding makes me go "huh" so I'd appreciate input... For example, say you have the following 2 cfcs: samplea.cfc <cfcomponent displayname="samplea"> <cffunction name="functiona" output="true"> In samplea.functiona. Calling functionb: #functionb()#. Calling functionc: #functionc()# </cffunction> <cffunction name="functionb" output="true"> In samplea.functionb. </cffunction> </cfcomponent> sampleb.cfc <cfcomponent displayname="sampleb" extends="samplea"> <cffunction name="functionb" output="true"> In sambleb.functionb. </cffunction> <cffunction name="functionc" output="true"> In sampleb.functionc </cffunction> </cfcomponent> You call the CFCs through the following (test.cfm): <cfobject component="sampleb" name="obj"> <cfoutput>#obj.functiona()#</cfoutput> <BR> <cfobject component="samplea" name="obj"> <cfoutput>#obj.functiona()#</cfoutput> Notice that the samplea cfc does not implement functionc() in any manner (even as an "abstract" function). However, the functiona() method in samplea calls a functionc(). sampleb cfc implements a functionc(). When I use the CFCs through test.cfm the first call works successfully since the object created is really an instance of the sampleb CFC which implements functionc(). However, the second call fails since it's creating an instance of samplea CFC. I understand how it works. My issue is why is this allowed? This muddies the waters between the parent and its children. It forces me to look at all the implementation details of a parent class to verify that it doesn't reference an undefined function that I'm expected to implement in my subclass. It seems to completely break encapsulation. If parents want to assume something about their children they should be force to write an empty method within the parent that children then override/implement. This is how a lot of code I've seen is written, and is likely a best practice, but when CF can enforce this contract more explicitly with better error messages to the developer why shouldn't it? What is the reasoning behind allowing this? Am I missing why allowing it is a good thing? Sorry if I'm repeating a conversation that took place 2 years ago. I'm a little behind. :) Bob PS - Caveat - this is how it works in my MX 6.1 install. Havn't worked with 7. >>> [EMAIL PROTECTED] 4/26/2005 4:30:58 PM >>> seems a bit muddled... you're always going to get methods of the current class (overridden or inherited) if you use variables.method(), this.method() or method() to call the method. Super.method() allows you to invoke a method of the parent class. So... technically polymorphism (forgive me if my memory is a bit rusty) is the ability to use subclasses with different functionality interchangeably... So, if you have another class which needs an object of type Ball to perform its function, it can use any sub-class of Ball which will have overridden methods, such as RubberBall.bounce() (which returns "high"), CannonBall.bounce() which returns "Yar!", or CheeseBall.bounce() which returns "splat". Am I missing something? (Other than the fact that I think if you specify <cfargument type="Ball"> it won't accept an object of type RubberBall, in which case I'd just omit the type argument. Conceptually a bit sloppy perhaps, but it's not a big issue for me.) Imo most of the functionality is there (sans interfaces) although some of it isn't as nice as it could be. > That's not polymorphism, that's overriding. While it's a > big part of > polymorphism, that's not all of it (at least in my own > view of what > polymorphism is...). However, I was wrong in my statement, > anyway - > <insert foot in to mouth>. A CFMX book I've been reading > talked about > how a parent class can invoke a subclass' overridden > method by > prepending the function call with "this.". This led me to > believe that > if you didn't prepend "this" to the function call the > parent's function > would be called rather than the child's overridden > function (this, of > course, assumes you're using an instance of the child > cfc). However, > after testing this in actual code I see this is wrong. > Bob >>>> [EMAIL PROTECTED] 4/25/2005 2:44:35 PM >>> >>>While I like the concept of CFCs and think >>>it's a great addition they lack of some OO capabilities >>>(polymorphism, overloading methods, etc) that limit what >>>you can do with them. ColdFusion, for all intensive >>>purposes, is a procedural language. > Why do you say CF lacks polymorphism? > parentClass.draw() = circle > -> descendantClass.draw() = square > That's polymorphism is it not? > Overloaded methods in my experience are reasonably easy to > simulate > with optional arguments, functions that accept variable > argument > types, slightly altered method names (getPropertyByID() - > getPropertyByName()), etc. No it's not technically > overloading, but it > accomplishes the same ends and is in my experience no more > difficult > to implement. > That being said, yes ColdFusion has procedural roots, and > personally > I'm still not entirely happy with it's OO implementation, > but not for > these two reasons (or for the lack of interfaces). s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/author/?id=4806 http://www.fusiontap.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204590 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

