Solved

Collection Puzzle

Posted on 2002-03-26
5
144 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

688 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