Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class inheritance versus Object (run-time) inheritance
Message
 
To
09/07/1999 14:20:47
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00238626
Message ID:
00239679
Views:
16
David,

Composition is not an inheritance. Composition only means to assemble multiple classes into one calss using containership (or ownership where one class owns the other classes). Another concept to consider is aggregation, whihc is combining of multiple classes together into a cohesive unit without containership. In VFP we can do both patterns, however composition is directly supported in our class heirarchies while aggregation is only supported at runtime through the mehtod of object creation adn the messaging methods used between those objects.

The difficulty with composition in VFP is found in the way the contained classes are treated. If you create a Container class and in that you put an instance of a textbox class and then subclass that container, the subclass is of a container, the textbox inside is not a subclass of the textbox in the superclass container, it is simply an instance of the textbox class.

What this means is that if the textbox in the 2st container use a DoDefault() call is one of its methods, that call is passed to teh textbox class that the one in the 1st conatiner is based on and not the textbox in the 1st conatiner. The 2nd conatiner's textbox is NOT a subclass of the one in the 1st container.

The solution to this problem in VFP is only use late composition, that is don't put any contained objects in the class definition until the very last subclass level, also fully define the contained classes on their own before assembling them into the composition.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform