Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NewObject or CreateObject or AddObject
Message
From
29/08/2007 01:16:46
Thomas Ganss (Online)
Main Trend
Frankfurt, Germany
 
 
To
28/08/2007 10:23:00
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01250745
Message ID:
01251073
Views:
18
>This has one very significant benefit for us as developers. Since there is a parent-child relationship Visual FoxPro can manage the garbage collection for us. By definition, an object which is contained, and owned, by another shares the scope of its parent. So when you destroy a composite object, all of the components are released also (Forms could not work if this were not the case!). This is not the case when you use aggregation, you must be especially careful to clean up any outstanding object references because VFP cannot resolve them for you.

About the only case where aggregation is preferred on controls able to function as a container is whenever you want to exchange the object depending on the task at hand. Some OOPurists argue to release the whole parent object and build a new one. I think loading a different object into the same property is better, even if you have to be careful of manual disposal.

regards

thomas
Previous
Reply
Map
View

Click here to load this message in the networking platform