Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
NewObject or CreateObject or AddObject
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01250745
Message ID:
01251027
Vues:
16
>Hi Marcia,
>
>>As a generally rule, I use Composition ( AddObject ) rather than Aggregation ( NewObject or CreateObject ) whenever possible because the container object "owns" all of the contained items. When the container is destroyed, all of its contained objects are destroyed too. So the chances of a dangling reference are greatly reduced.
>
>The only reason this matters is because of VFP's buggy garbage collector <s>. AFAIK child object references are still released before the Destroy() of the parent object fires so the difference between a container and an actual object reference doesn't make that much of a difference. Certainly it's easy to have a dangling reference that won't clean up either way...
>
>The key issue for this often is order of how objects are released and the only real safe way is to explicitly release the objects. In Web COnnection 5.0 for example I've had major issues with this very issue and I experimented around with different classes, containership etc. before just using Custom classes and properties, but firing an explicit Dispose() method whenever objects release with that method implementing the required release sequence. It works, but of course requires that control developers pay close attention to implementing a Dispose() method properly.
>
>+++ Rick ---

Hi Rick,

You may check Re: Automatic Destroy method Thread #1246863 Message #1247285
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform