| To: | "Rich Schramm" <richard.schramm@xxxxxxxxxxxxxxxxxx> |
|---|---|
| Subject: | Re: [cinjug-users] Calling methods of sibling objects |
| From: | "Keshav Kode" <keshav.kode@xxxxxxxxx> |
| Date: | Sat, 18 Aug 2007 01:06:23 -0400 |
| Cc: | users@xxxxxxxxxx |
| Delivered-to: | mailing list users@xxxxxxxxxx |
| Dkim-signature: | a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=cF1XIKCMOjF7/IClF+42ovK7IXDGhz9NmGlWVpVqD7D67QMB80w7+8iDCRqQOeuehZx10YKHnIn+GM4uHe/A2usguAFkJ8IhBVTR9IlmElvFWa4D+dT7aYEc52Fwv36kBjakG3jPB4GJzpPMki3R7swsg3Eem5yysz1Xi0fDsuA= |
| Domainkey-signature: | a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=UvxMWcNN06bwUmW8cqPKA9cpvc1Fsz0sH5fPe2kthZ8XIEf6EGKxGnhuih7KwxK1Ap0DTS4r2pk2xWkAJVmDek9IYXWn6g7vvLskzAhVeCZ8Dsj959/d5E7pYDvUNxoykkxb5ZkoEZHN7qafFFQ7MgOnLJwiBA2gWYKW507XSuM= |
| In-reply-to: | <BCDB7761EF65A54B92F46CD400D1D2D96330F5@xxxxxxxxxxxxx> |
| Mailing-list: | contact users-help@xxxxxxxxxx; run by ezmlm |
| References: | <BCDB7761EF65A54B92F46CD400D1D2D96330F5@xxxxxxxxxxxxx> |
|
Rich,
One way to do this is to make 'Smart Child' object. What I mean is in each child object keep sibling reference. Getter & setter in Parent object maintain this sibling references. So at any point in time each child knows who is its sibling object and can invoke method directly.
Overall, you have to take this pain either ways. Either you do work ahead of the time when building the tree or you do work while method invocation. The design decision will depend on how many times the method is called in given business scenario and how many times you change the object relations.
Parent +--- Child1 child_1 getter / setter +--- Child2 child_2 getter / setter
Child1 +--- Child2 sibling getter / setter +--- Other Child1 attributes +--- method1()
Child2 +--- Child1 sibling getter / setter +--- Other Child2 attributes +--- method2()
Another approach could be that you externalize this relationship management and create RelationShipManager class. Sole purpose of this Class is to manage object relationship. Anytime you set or remove child call this manager and you query this manager for any object in the tree. Again it depends on how sophisticated you want to be in your design. Hope this helps.
Keshav.
On 8/17/07, Rich Schramm <richard.schramm@xxxxxxxxxxxxxxxxxx> wrote:
-- Thank you, Keshav Kode Keshav.Kode@xxxxxxxxx |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: [cinjug-users] Calling methods of sibling objects, Rich Schramm |
|---|---|
| Next by Date: | Re: [cinjug-users] Displaying which JVM in a cluster., Edward Sumerfield |
| Previous by Thread: | Re: [cinjug-users] Calling methods of sibling objects, Abdul Habra |
| Next by Thread: | Displaying which JVM in a cluster., ENapier |
| Indexes: | [Date] [Thread] [Top] [All Lists] |