Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Superclass
Message
 
À
23/05/1997 18:24:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00033281
Message ID:
00033505
Vues:
49
> > >> But you can define a Behavior class. This Behavior must have all common > >> methods. Your classes will have a property that will keep a reference to > a > >> Behavior object. All methods for this classes will just call the the > >> corresponding methods of Behavior object. > >> > > > >Vlad, I like the idea of a behaviour class, but why not give each base > >class a behaviour class (or is this what you suggest?), to be > >instantiated with addobject. This is the way one works around the lack > > I like the idea too. All tributes go to Steven Black who (AFAIK) is the > author of it. But, anything I say here is my opinion, not his. > > If you use AddObject to create the Behavior object, it will be linked to > the container and it will be added to the collection of objects within the > container. There are some disadvantages: I have found out that you can work around this: if you define a property in the parent object and issue ... this.Property= createObject('BehaviourClass') ... in the parentClass.Init method. It has all the advantages of the addobject method, without the disadvantage of the parent class having to be a container. > > 1. You will have the following relations between objects (triangle of > relations): > Container->Behavior > Container->AnObject > AnObject->Behavior This, to be honest, I do not understand. > This means that you must write additional code to be able to destroy these > obects correctly. You do this in the base classes no? > 2. The container will be loaded with some (usually) non-visual objects. So ? > 3. It reduces the generality <snip> The price to pay to use composition i.o. inheritance ... > > >of 'multiple inheritance' (Doug is that not what you were looking for?). > > As far as I understood he wants to have the same methods for different > classes, not multiple inheritance. This implies to have a class as ancestor > for all/some your classes. Which is impossible in FoxPro. This is why he > said "Superclass", I think. Yes. But this problem would be solved (and others probably created) if we had multiple inheritance, i.e. that a class could inherit from multiple classes (i.o.w., multiple superclasses). > > >This way all the base classes can share methods _and_ properties ... or > >am I missing something? > Well all the properties that are owned by the behaviour class are accessible by the objects of classes that own this behaviour class. Or is something else meant by 'sharing properties'? >SNIP Thanks and regards, Marc

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform