tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/717-mediator-optimizationRobotlegs: Discussion 2018-10-18T16:35:34Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/114836502011-11-17T10:27:10Z2011-11-17T10:27:10ZMediator optimization<div><p>Hey,</p>
<p>I have a situation when: I create many (several hundreds)
objects which update their properties with model. But also, when
model changes, they update themselves if changes related to them.
My questions is: what is faster, create mediator for every object
and make them dispatch/listen to events from model by themselves,
or create a manager class which is listening to this event and
sorts it to those objects which are related to model update?</p>
<p>ps</p></div>pstag:robotlegs.tenderapp.com,2009-10-18:Comment/114836502011-11-17T10:52:38Z2011-11-17T10:52:39ZMediator optimization<div><p>If there aren't several hundred sorts of changes that the
objects(views?) are interested in, I'd create a single mediator and
mediate a parent object, that forwards the changes to the many
objects. So the answer is to create both (a manager object) and a
single mediator, that mediates it.<br>
Of course the above makes less sense if those objects aren't
related to each other in some way.<br>
Hope this helps.</p></div>Vladotag:robotlegs.tenderapp.com,2009-10-18:Comment/114836502011-11-17T10:59:39Z2011-11-17T10:59:39ZMediator optimization<div><p>Another option is to use a single mediator and then use this to
dispatch signals which are injected (manually, doesn't have to be
using auto DI) into the views.</p>
<p>If you're familiar with signals and want more info on this
approach, shout.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/114836502011-11-17T11:12:40Z2011-11-17T11:12:40ZMediator optimization<div><p>@Vlado objects(views) are not related to each other so your
solution should be OK. One thing which worries me is that I have to
store them in an array (so they are not independent), and then
clear them manually. The thing is not easy cause those objects are
different classes in different containers etc. I would have to
manually administer GC.</p>
<p>@Stray, yes, I'm using signals in my project. (Signals,
SignalCommand, SignalMediator). I would like to hear more on this
approach please.</p></div>ps