tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/1205-specifying-an-mediator-interface-instead-of-mediator-class-in-the-function-tomediatorinterfaceRobotlegs: Discussion 2018-10-18T16:35:47Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/261329772013-03-29T08:37:20Z2013-03-29T08:37:20ZSpecifying an Mediator interface instead of Mediator class in the function ---> toMediator(<Interface> ); <div><p>No, you can't and IMO it doesn't really make sense. Mediators
are tightly coupled to an interface/class, by definition, so you
wouldn't benefit from adding an extra abstraction to it.<br>
The only reason I could see to allow this is when you're mapping
the same mediator to a large number of different
interfaces/classes, but that's definitely a code smell that your
mediator is doing too much and violates SRP.<br>
But maybe I'm mistaken and this could be really beneficial. If you
can think of a use case let us know!</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/261329772013-03-30T05:27:39Z2013-03-30T05:27:39ZSpecifying an Mediator interface instead of Mediator class in the function ---> toMediator(<Interface> ); <div><p>mediatorMap.map(Interface ).toMediator(Mediator Class );
<<< map() parameter is "interface", toMediator() parameter
is a "class" .</p>
<p>The above is what i am actually doing presently. In my present
project, I need to attach a single Mediator with an unknown number
of Views ( sort of plugins).The application is divided into two
sections. One is the main application. While the other section is
view ("plugin") creator. The main application creates a set of
interface in an "swc" . This swc can then be used by another
section to create views. This section creates "swf" as views. Which
is accessed by "main" application via an xml file. Their can be "n"
number of views ( implementing particular interface, known to main
application)</p>
<p>When the main application is run, it shows the "n" number of
tabs ( views/plugins) , depending upon the entries done in the xml
file.</p>
<hr>
<p>However, what i was asking was this :</p>
<p>mediatorMap.map(Interface ).toMediator( Interface ); // <<
NOTICE that unlike above case, the parameter of toMediator() too is
an interface. Not a class.</p>
<p>However, this one seems like, will produce an error.. as i
think, there must be some concrete specification as a parameter to
toMediator() , otherwise, how would it know, which class to
instantiate.</p>
<p>V.</p></div>vishwas.gagranitag:robotlegs.tenderapp.com,2009-10-18:Comment/261329772013-03-30T10:31:37Z2013-03-30T10:31:37ZSpecifying an Mediator interface instead of Mediator class in the function ---> toMediator(<Interface> ); <div><p>Yes, it will produce an error. You can only map concrete classes
as mediators.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/261329772013-04-01T20:26:54Z2013-04-01T20:26:54ZSpecifying an Mediator interface instead of Mediator class in the function ---> toMediator(<Interface> ); <div><p>ok. thnx!</p></div>vishwas.gagrani