puremvc
|
|
« Reply #1 on: July 18, 2008, 10:49:53 » |
|
If you send the data, it is a looser coupling.
While it's an accepted practice to retrieve the Proxy and get the data, if this one Notification introduces the coupling then pass the data, don't make that coupling and be better off for it.
Sometimes a Mediator and a Proxy will communicate often enough, we design the Mediator to retrieve and cache a reference to the Proxy at onRegister so that it doesn't have to retrieve many times throughout runtime. If this is the case and a collaboration has already been established between a Mediator and a Proxy, and that Mediator will be the only observer, feel free to omit sending the data so you don't need to cast the note body. Allow the Mediator to access a typed getter on the Proxy instead.
And if it will be a Command that uses the data, if that Command does nothing else with the Proxy except retrieve the data, then send the data in the note body and let the Command cast it, omitting a call to retrieve the Proxy, since the Command will go away after execution and would have to do that retrieval each time.
-=Cliff>
|