Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AddObject/RemoveObject
Message
 
À
22/03/2002 10:35:35
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00635975
Message ID:
00636067
Vues:
29
>However, I like the elegant simplicity of working with arrays. Looping through an array is somewhat easier (for instance, to set all CheckBoxes to true).
>
>And with an additional array, it seems to me that the array has to be set to NULL before releasing the form.
>
>Nothing extremely complicated perhaps, but I thought that my solution was simpler. I am not sure now.
>

Hilmar,

The form has a collection of controls named Controls so you don't need this functionality, you already have it. Unless you are creating objects based on base classes that cannot be contained in a form (like forms themselves).

BTW, this whole discussion is revloving arround an essential OO issue. That being that objects that contain other objects MUST celan up after themselves.

Your question about memory leaks is really only relevant because you have not made the form clean up its space on destruction. If you use AddObject the way it is intended then the form will automatically destroy the objects added. However, if you are using the array technique you described then YOU must clean up after yourself as the objects created are not truly objects contained in the form but rather are objects to which the form holds a reference. This is the difference between containership and aggregation, the array is using aggregation while the simple AddObject is using containership.

In VFP the containership model will clean up automatically while you must clean up the aggregation.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform