>>>I have a business class that has a property DA_OBJECT referencing data access class. The DA_OBJECT is instantiated in the INIT method of the business class. I need to destroy the DA_OBJECT when the business class is destroyed. Since my business class is based on the CUSTOM class I am thinking to add the following in the Destroy method:
>>>
>>>
>>>this.DA_OBJECT = .NULL.
>>>dodefault()
>>>
>>>
>>>Is the above correct approach?
>>>
>>>Thank you in advance.
>>>
>>>UPDATE: I am actually using VFP 9 SP1 (not SP2).
>>
>>I think it is correct. I have seen this in the framework I use, pressumably to avoid dangling references (which can sometimes cause the form not to close completely).
>
>
>They always keep the form alive, don't they?
Yeah, I think the problem arises when an object A has a reference to object B - and vice versa. An object is destroyed when it has zero object references, but this "deadly embrace" can avoid either of the two objects from being destroyed. And both objects might be properties on the same form. But I don't know much more about this; like, being able to give specific repro code.
I also understand that this is different in languages that use garbage collection (like Java, for instance), where the two objects, in the above example, are unreachable from some initial set of objects, and will eventually be destroyed.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)