Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To Class or not to class
Message
De
10/04/2018 13:45:11
 
 
À
10/04/2018 09:19:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01659269
Message ID:
01659290
Vues:
57
>>>I am about to convert a huge inhereted prg file into one .vcx and wonder. The prg file consists of multiple procedures and multiple functions. Should I put each individual function in a separate property and also should I put each individual function in a seperate function?
>>
>>In the November FoxRockX, I had an article with code to break a procedure file into separate PRGs.
>>
>>My take on this is that if the functions operate on shared data, then it makes sense to create a class and store the data as properties and make the functions methods. If the functions are independent of each other, then make them stand-alone functions.
>>
>>Tamar
>
>Tamar,
>
>I now have a large .prg file for your info, Foxadvisor may 1998, page 56 "Network.prg" by George Tasker. I would like to convert this prg file into one .vcx (Network.vcx based on custom) and my question is do I have to create separate methods for each procedure and separate methods for each function. To store them into separate .prg files is not making the new class more compact on the contrary it will be converted into 4 new funtion.prg's and 1 new class.vcx, I can than just as well work with one prg file.
>

I don't really understand your question. If you turn procedural code into a class, then the procedures and functions become methods. In my view, you should only do that if there's data they all need to share that you'll store as properties. If they're really independent routines that aren't operating on shared data, why make a class of them?

That said, I realize what you may be asking is the process of moving from a PRG to a class in a VCX. To do that, CREATE CLASS xx of yy, add any properties you need, and add custom methods with the same names as your existing functions. Then cut and paste the code from each function into the right method of the new class.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform