Link to home
Start Free TrialLog in
Avatar of crystaltips
crystaltips

asked on

Collection Puzzle

Consider..

Parent -> Children -> Child

I want to include the method 'ChangeParent' method in the Child object.  

This is primarly used when a Child object is created in isolation! eg...

Dim oChild as New Child
Call OChild.ChangeParent(NewParentId)

If the Child object was created as part of the above heirarchy ( Parent -> Children -> Child )... what is the best way of informing the Parent object that a Child object has fired this event???????

Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

usually, I have the Parent object be responsible for creating ITS Own children objects, and then give the Child Object a SetAsParent method, which accepts a Parent Object as the argument (and then in the Parent, when the Child Object's SetParent method is called, pass the Reference Me (of the parent).)  

After all, in the world that the Parent-Child model is mimicing, don't REAL parents create their own children, and the Child then KNOWS what parent it belongs to.(Didn't YOUR parents "create" you, and thus didn't YOU know who your parents were?)  Children should NOT be create in a vacuum, whether that be in a program, or in the Human-world.

Arthur Wood
Avatar of crystaltips
crystaltips

ASKER

Thanks for the insight Arthur!

In the same vein, can't a child decide to leave its parents?

Perhaps the Parent/Child analogy was misleading.

Consider..

God->Children->Child

God can manage children without the parents' knowledge.
God decides that a Child object shall have a new parent.

How do I inform an instantiated Parent object that it has lost a child?





ASKER CERTIFIED SOLUTION
Avatar of zafarbhat
zafarbhat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- split points Arthur_Wood and zafarbhat
Please leave any comments here within the
next seven days.
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange


Arthur_Wood: points for you added to:
https://www.experts-exchange.com/questions/20463733/points-for-Arthur-Wood-re-20292800.html