Passing Object N Level Deep
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Grzegorz_Bugaj
Posted On:   Monday, April 24, 2006 01:38 PM

Hi, I am having design problem with my app. This is my scenenario: Object A Object B Creates/modifies Object C Object D modifies Object C Object C then gets passed back to object A This is all done using get/Set method and is not very effective. Some of the objects: WorkQueueMetrics MemoryMetrics RequestTracker If I add new object of some sort, I have to create set/get methods all the way the chain, it works but I would like to find a better solution. Thanks in advance    More>>

Hi,

I am having design problem with my app.


This is my scenenario:



Object A

Object B Creates/modifies Object C

Object D modifies Object C



Object C then gets passed back to object A



This is all done using get/Set method and is not very effective.

Some of the objects:

WorkQueueMetrics

MemoryMetrics

RequestTracker



If I add new object of some sort, I have to create set/get methods all the way the chain, it works but I would like to find a better solution.


Thanks in advance





   <<Less

Re: Passing Object N Level Deep

Posted By:   Jani_Kaarela  
Posted On:   Tuesday, April 25, 2006 02:55 AM


I suggest three tools:


  1. Separation of concerns

  2. Delegation

  3. Constructor args




By separation of concerns, I mean that you should avoid having getters/setters "propagate" through the whole object graph. An object shouldn't be concerned about the whole "chain" or graph of objects. You can hide details further down the chain by delegating instead of directly accessing objects. This not only reduces getter/setter clutter, but also keeps the whole more manageable by reducing the "connections" (ie. references) between objects.

About | Sitemap | Contact