Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error : Illegal redefinition of variable
Message
De
25/07/2013 10:37:16
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01579124
Message ID:
01579205
Vues:
50
>I believe this is a bad practice, but this is my personal opinion. If a variable is PUBLIC, then the
>programmer must assume that this variable is available at all times. Otherwise it would not be
>public. If you declare the public variables at a point in time later than main.prg, you can fall into
>the trap to add later functionality or reuse code that makes use of those public variables, and
>call that code before the variables are declared. There is not a practical way to properly document
>this in the code and it can create program errors that are very difficult to trace.

Write a program that inserts a check at the location of every PUBLIC definition to see if it's already defined. You can then identify all cases just by running the program through its paces.


>>(2) To prevent the need for initializing variables within a oft / repeatedly called function
>Again here you can create objects that are instantiated at the beginning and when passed
>as parameters they will be available in the repeated function calls.


You're still creating and passing unnecessary things to the called functions. And you're still dealing with objects, which means looking elsewhere for accessor methods and other variables.

SometimesAlmost always simpler is far, far better for readability, understandability, and long-term maintenance. PUBLIC variables definitely have their place. Depends on many factors. Code should be clean and self-explanatory, not buried under layers of classes.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform