Information générale
Catégorie:
Codage, syntaxe et commandes
All my variables are declared at the top of the func/proc/method. The performance gain of declaring them where needed is too small and the gain of having all variables declared up front is too big. :)
From experience I've learned that variables declared "somewhere" are one of the most important source of bugs when working in a team or during code maintenance.
I don't initialize variables at top if they don't have to have a default value.
The same goes for my C/C++ code (IMO, the problems generated by variable declarations anywhere in code are even more "sweeter" in C++ :)).
Vlad
>Ok all - poll of the day:
>
>Do you declare (LOCAL, etc.) all your variables "up front" in each method/prg or do you declare them only when they're about to be used first time within the method/prg as in the case of conditional branching where the variable may not be used at all except under a particular case?
>
>I've seen use of and arguments for both. Just like to see what everyone is doing. Also how do all of you feel about the practice of always giving a local variable a default value up front or wherever it is declared?
>
>TIA!
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement