Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NewObject or CreateObject or AddObject
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01250745
Message ID:
01250989
Views:
15
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 ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform