Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Classes - Best Practices?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00763778
Message ID:
00765176
Vues:
22
Okay, given the responses that I've gotten so far and the experimentation that I've done on my own, it really looks like VFP was designed around the idea that classes - visual or non-visual will be in VCX files.

If I put each class in a separate .PRG file I need to use a sequence of SET PROCEDURE TO ... ADDITIVE commands to use them within my apps and they won't show up in the class browser at all - at least not that I've seen.

However, if I put them all in a VCX file I get the benefit of them showing in the class browser and being able to add them all with one SET CLASSLIB TO... command. While I would prefer having everything in code, it looks like I basically have to fight VFP to do it. So I'm leaning toward the VCX files for ease of use - even though my classes are not visual.

So I have another question...
Two things that I really like about VB are constants and enumerations. I like being able to scope my constants as public or local. VFP doesn't provide that exactly, though with #DEFINE...#UNDEFINE you can approximate that behavior. Enumerations appear to be out of the question as well.

Is there a way in a visual class to use #DEFINE to create a constant that is available to any method in the class? For that matter, can you create a non-public variable that is available to any method in the class? It doesn't appear that it's possible from what I've tried so far. A constant declared in the Init event does not appear to be available to a user-defined method. And variables only seem to be available if created as PUBLICs.

With the .PRG approach, I can create constants at the beginning of a class definition and #UNDEFINE them afterwards and have, in effect, a class level constant. I don't think I can do the same with variables as any variables declared at the class level become properties.

Any thoughts?
John Groft
Consultant
Computer Task Group, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform