?
Solved

Collection Puzzle

Posted on 2002-03-26
5
Medium Priority
?
145 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

770 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