Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Programming Standards Documentation
Message
De
16/06/2004 17:40:54
Anthony Testi
Fabtrol Systems Inc.
Eugene, Oregon, États-Unis
 
 
À
16/06/2004 17:21:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00914339
Message ID:
00914466
Vues:
7
>Method XYZ( )
>  Local llTemp_Answer
>  llTemp_Answer = Some_Function_Call_That_Takes_a_long_time( )
>  This.Atribute1 = llTemp_Answer
>  This.Atribute2 = llTemp_Answer
>  This.Atribute2 = llTemp_Answer
>  Release llTemp_Answer
>  ....
>
> llTemp_Answer will be released anyway at the end. IMO, that line isn't needed.

Correct that VFP will release the Var ( thank God for Good Garbage collection in VFP )
I put it for these reasons:
-The person reading this example will see that Var is not used anymore.
-If this was real code the above again would be true. The original developer has stated that they are not going to use this var again. If the RELEASE is not there I wonder did the developer forget to use this value and did not complete the routine?
-As Code Complete points out the longer a vars life time is the greater the chance of error, I want to reduce that problem by explicitly releasing the var. Yes that may apply more for languages like C/C++ but I think it is good advice and I have taken it to heart.

Now if I within a few lines of the end of the routine I may not do it, because as you point is will be release soon anyway.

This of course something that could go into a Standards doc. Where in a routine does one scope vars? At the top of the routine, just before the first use of it in the code ( what I tend to follow ) and when does the var get release? Let VFP do it, or when the var is not needed ( I release as soon as practical )

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

Click here to load this message in the networking platform