Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Observer Pattern: Dangling References
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00354611
Message ID:
00354667
Vues:
15
Ken, I think the problem here is illustrated on the wiki at
http://fox.wikis.com/wc.dll?wiki~RelationshipHeuristics.

Namely:
* When given a choice in object-oriented design between a containment relationship and an association relationship, choose the containment relationship.
* Objects that share lexical scope should not have 'uses' relationships between them.

The problem here, heuristics aside, is that in VFP the destroy event is really late in the physical destruction process. It's beyond the point of 'no return', I know that. Also the destruction is z-order based, and it's hard to be sure which objects at the same lexical scope go before others.

I recommend container-based observers for this reason. In VFP, if you have a form with a container with a control in the container, the destroy sequence is
Form
Container
Control in the conttainer (first in, first out)

Thus if your observer can be the form, or the container the controls are in, or attached by reference to the form or container the controls are in, you leverage the destruction sequence by making sure the observer is toast before the controls are killed.

The key is to avoid having objects at the same level of lexical scope permanently attached by reference. VFP 3 and VFP 5 often just GPF when you release a system like you describe...

Andre
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform