On Sunday, September 1, 2002, at 08:27 , Jeffry Houser wrote:
>   I almost skipped over this post because it was all quotes.  ( I imagine
> that was because the list was bouncing stuff for a bit).

Yeah, sorry about that.

> 3. Is the data created inside a component protected from outside
> forces?  I'm a little grey on this one.  You can create component specific
> variables using the this scope.

"this" scope is public, the unnamed scope is private so this gets a YES.

> 2. Do CFCs support Overloading / Overriding?  Not in related objects.

Overloading no, overriding yes. (And I don't really agree that overloading 
is actually *necessary* to claim 'OO-ness' - much of the worst code I have 
seen in OO languages is because of overloading and there are almost always 
ways around it).

> A child CFC inherits all parent
> methods as is.  You do not have the ability to change functionality of
> inherited methods.

Yes you do. Try the following:

        // base.cfc:
        <cfcomponent>
                <cffunction name="foo" returntype="string">
                        <cfreturn "I'm base.foo"/>
                </cffunction>
        </cfcomponent>

        // derived.cfc:
        <cfcomponent extends="base">
                <cffunction name="foo" returntype="string">
                        <cfreturn "I'm derived.foo"/>
                </cffunction>
        </cfcomponent>

        // test.cfm:
        <cfset b = createObject("component","base")/>
        <cfset d = createObject("component","derived")/>
        <cfoutput>
                b.foo() is #b.foo()#<br>
                d.foo() is #d.foo()#<br>
        </cfoutput>

You can pass d to anything expecting a base component instance so 
substitutability is preserved and polymorphism is also preserved.

> 3. Do CFCs support inheritance?  Yes, they do.  However without the
> overloading / overriding it is nothing more than a fancy include.

Overloading is mostly irrelevant for inheritance - in most (all?) OO 
languages, when you inherit an overloaded set of methods, you have to 
reimplement all of them in order to preserve overloading - overloading 
normally only occurs within each class definition.

As pointed out above, CFMX does have overriding so inheritance *is* more 
than a fancy include.

> 4. Do CFCs support polymorphism?  I would say no.  I cannot create two
> different methods with the same exact name, but different argument
> types.  That is the essence of polymorphism.

No, that is overloading. Polymorphism requires overriding - see above - so 
CFMX  *does* support polymorphism. Polymorphism is 'virtual functions' in 
most every OO language, something that CFMX does have.

> For me, the lack of the ability to overload is what makes me
> say you cannot apply Object Oriented development

As I say above, overloading really has nothing to do with OO. C has 
overloading (Oh, yes, it does! Check out the latest ISO C standard to see 
how they worked that in. Not for all types, admittedly, but they did add 
it).

(Do I need to mention that I wrote the first ANSI-validated C compiler, 
spent eight years on the ISO C++ Standards Committee - three as secretary 
- designing parts of that language and also worked on the UK and ISO Java 
Study Groups for a couple of years as well? :)

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to