Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multiple procedures vs. one procedure - revisited
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01022173
Message ID:
01022268
Vues:
12
I think I agree with Cetin.

I prefer to have classes, in one or more prgs, and then there is no need to ever use SET PROCEDURE TO, for example:
* MyClasses.PRG

define class StringFunctions as Custom && Or whatever, String related functions
  function myStringFunction1(myParametersList)
  endfunc

  function myStringFunction2(myParametersList)
  endfunc
enddefine

define class ArrayFunctions as Custom && Or whatever, Array related functions
  function myArrayFunction1(myParametersList)
  endfunc

  function myArrayFunction2(myParametersList)
  endfunc
enddefine

define class DataFunctions as Session && This are functions that will use tables, thus I use Session as baseclass
  function myDataFunction1(myParametersList)
  endfunc

  function myDataFunction2(myParametersList)
  endfunc
enddefine
Then in programs or forms or classes
loDataFunctions = newobject('DataFunctions', cSomeBasePath + 'MyClasses.PRG') && or
thisform.DataFn = newobject('DataFunctions', cSomeBasePath + 'MyClasses.PRG')
...
loDataFunctions.myDataFunction(someParameterList) && or
thisform.DataFn.myDataFunction(someParameterList)
This way you get rid of SET PROCEDURE altogether, and with that you get rid of some code, for example you do not need to store the current set("procedure") at the beginning of some processs and then restore it back at the end, something you should do, in particular if there are chances that the PRGs have some common named functions
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform