users
[Top] [All Lists]

Re: [cinjug-users] Calling methods of sibling objects

To: Rich Schramm <richard.schramm@xxxxxxxxxxxxxxxxxx>, users@xxxxxxxxxx
Subject: Re: [cinjug-users] Calling methods of sibling objects
From: Abdul Habra <ahabra@xxxxxxxxx>
Date: Fri, 17 Aug 2007 12:51:34 -0700 (PDT)
Delivered-to: mailing list users@xxxxxxxxxx
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=YsgNUNWCBuRiLNQRAG4a58T4NRuEtesed9mK6ghLx4FdWDKmUWLImDr6e0fxKkj1/reWE96EoKVQkL3Qhi82S3UJuA++zKev5OIj4CBAIuP4DOvtJXQAwReLWZbnBakFVDOcX1y2DyGtvAoWTkkPmp5wn9zRggglicdBsHnWAp4=;
In-reply-to: <BCDB7761EF65A54B92F46CD400D1D2D96330F5@xxxxxxxxxxxxx>
Mailing-list: contact users-help@xxxxxxxxxx; run by ezmlm
child2 has to have a reference to parent.
you can set it either in the constructor of child2, or in a setter method in child2.
of course this assumes that you are not going the reflection route.
 
to nit pick, in OO terms, you are describing an aggregation relation not a parent-child
so it is a little confusing to call them parent/child.
perhaps container/element is better?


Rich Schramm <richard.schramm@xxxxxxxxxxxxxxxxxx> wrote:
Hi,
 
Hoping this is not a dumb question, maybe someone call help.
 
The object model for my application contains a parent object (Parent) that has two other objects as properties (child1 and child2).  In child1, there is a method (method1) that I want to call from child2.  However, I am stumped on how to get a handle to child1 or even the parent from within child2 without having to pass a reference to child2 from a method in parent.  Is there a way to call parent.child1.method1() from within parent.child2?
 
Thanks,
 
Richard Schramm
Supply Dynamics, LLC.
513.965.2000 x14 (office)
513.300.7851 (mobile)
 


Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.
<Prev in Thread] Current Thread [Next in Thread>