Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PageFrame infomation not inheriting
Message
 
À
21/08/1997 19:56:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00046213
Message ID:
00046526
Vues:
25
>Thanks for the advise! I'll give that some thought. The reason I was making a base class "form" is because we had several forms that were very similar, so we made a base-class with all the common controls, then subclassed that to make the final forms to avoid duplicate work. Is this a bad aproach?
Lee,

As I said before, I would design the controls as a separate class heirarchy, then build the fomr classes by putting the appropriate controls in them just before the calss is used to create objects. IOW, I would not assemble the fomr and then subclass it, I would subclass controls outside of the form until they were what the form needs, then assemble the form form these control classes.

The concept of composition in not a simple one, however the earlier the composition the less malleable the subclasses are, for example imagine a class tree of forms with a PageFrame. The first class would be the fomr with a pageframe in it. Now some of the subclasses need three pages and some need five pages. How would you construct the pageframe in the base fomr class? If you give it five pages, those forms that only need three have a problem as you cannot remove pages that are defined in the parent class. If you design the base fomr with only three pages you can't give that class any code for hanlding the other two pages because they are not there.

My suggestion is that you create the base form class without any pageframe in it (this is an abstract class as it is not intended to ever be used to create an object). You also create a class tree for the pageframes, and then when you are creating the form class that will actually get instantiated (this is called a concrete class as it IS used to create objects) you put the appropriate pageframe class in it.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform