Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sub-Classing
Message
De
04/02/1999 12:55:20
 
 
À
04/02/1999 09:35:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00183841
Message ID:
00183962
Vues:
14
>Hi --
>I am very interested in learning the mechanics behind sub-classing, however, I could use a little advice from the developers on this thread. Everyone I have talked to on UT has said how crucial it is to have sub-classing, and that simply using base classes is not enought to create powerful applications.

VFP is powerful, subclassed controls or not. Where subclassing brings power is flexibility down the road. The ability to make every grid in your application behave a certain way by changing properties or code in one place. That is power, and you can't do that if your controls are dereived from the base classes.

>I am still not clear on the best way to tackle this project.

I remember the feeling.


>I have been instructed me to make all my classes, OLE Public.

This is absolutely unnecessary. Making a class OLE Public means that that class can be instanciated from other OLE applications. While this is very powerful and important functionality for many reasons, most applications don't need a single OLE interface, and the ones that do only need one or two classes to be public.

>1. Do I make my base classes OLE Public, or my sub-classes?

Neither. See above. If and when you do decide you need to have a class OLE Public, you'll want to make the exact class, not one of its parents.


>2. Do I have to know exactly how I want my forms to work before i can create sub-classes?

No. There are two ways you can approach this:

1. Just jump in and start coding. Start with nothing more than your subclasses of the base classes, and start putting forms together. This is how I started, and while it proved very valuable to my learning experience, I don't think it was the most productive way.

2. Either buy a commercial framework, or get ideas from commercial frameworks and other people who have built custom frameworks. There are lots of things tht end up being useful in an app that aren't obvious fromthe get go; an application object, a form manager class, etc. If you still want to roll your own steal ideas from those who have done it before you. In software, this is not theft, it is being efficient.


>I think the problem I am having, is that I don't know what sub-classes to create, or what to name them for that matter. I haven't done this before, so I don't know what I am trying to accomplish.

A good rule for base class names is the standard 3 letter initial for the control type, followed by the word "base", to let the name tell that this is your base class, and there are no parents from here on up, besides tha VFP base.
cboBase, txtBase, lblBase, grdBase etc.

From there, you'll probably quickly find out that you want a subclass of every control that is bindable, so your databound controls can have their own functionality: txtDB, cboDB, etc.
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform