Re: VFP6 & OOP - newbie question

Author: Mary Hintermeier, mhinterm@RSA-NET.COM

Posted: 1999-09-14 at 09:46:44

You got it exactly right Stuart.

The beauty of subclassing and VFP is that you can completely override the

behavior of a method in a subclass and the class interface doesn't change.

A better design may have been to have an AbstractPoly class which has just an

Empty Show method() and then subclass into PolyWaitWindow and PolyPrint

AbstractPoly Show method does nothing

PolyWaitWindow Show method shows stuff via WAIT WINDOW

PolyPrint Show method show stuff via ?

Although the implementation of the Show method in each subclass is different,

the interface into the object remains the same in all classes. So if I want to

write a program which initially does wait windows I can do

At design time or in a separate program/class I can do

this.cPolyClassToInstatiate = 'PolyWaitWindow'

In a standard program used regardless of the actual implementation of the Show()

method

loPoly = CREATE(this.cPolyClassToInstatiate)

loPoly.Show()

And then later, if I change my mind, I just have to change the calling

program/class to do

this.cPolyClassToInstatiate = 'PolyPrint'

"AMS Computing" <computing@dial.pipex.com> on 09/14/99 09:22:58 AM

Please respond to profox@leafe.com

To: Multiple recipients of ProFox <profox@leafe.com>

cc: (bcc: Mary Hintermeier/RSA)

Subject: VFP6 & OOP - newbie question

Okay so I am thick, but does the Polymorphism donkey upset Inheritance cart?

Using an example from a book to explain Poly...

*****

DEFINE CLASS xPoly AS custom

PROC show

WAIT WINDOW 'This is the root class'

ENDPROC

ENDDEFINE

DEFINE CLASS xPolyChild AS xPoly

PROC show

? 'This is the child of xPoly'

ENDPROC

ENDDEFINE

SET PROC TO ...

oTest = CREATEOBJECT('xPolyChild')

oTest.Show()

****

Only shows the child not the parent, unless I included DODEFAULT() in

xPolyChild.Show

Is this correct, it does make sense?

regards

Stuart Hurley

ams_ltd@dial.pipex.com

©1999 Mary Hintermeier, mhinterm@RSA-NET.COM