Solved

Collection Puzzle

Posted on 2002-03-26
5
142 Views
Last Modified: 2010-05-02
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???????

0
Comment
Question by:crystaltips
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6898111
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
0
 

Author Comment

by:crystaltips
ID: 6898413
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?





0
 

Accepted Solution

by:
zafarbhat earned 50 total points
ID: 6898662
One way can be that you remove the Child from the current parent's Children collection and then add it in specified parent's Children collection.

This will need to be done in the procedure ChangeParent(vv)

Zafar Iqbal
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7754775
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.
0
 

Expert Comment

by:SpideyMod
ID: 7811673
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange


Arthur_Wood: points for you added to:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20463733.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question