tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/2313-some-kind-of-mapping-betwen-vo-and-viewRobotlegs: Discussion 2013-06-25T09:33:01Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/268530282013-05-16T07:56:52Z2013-05-16T07:56:52ZSome kind of mapping betwen VO and View <div><p>The easiest solution that comes to mind is to map the VO classes
to view classes:</p>
<pre>
<code>public class NodeViewFactory implements INodeViewFactory{
private var _viewsByVOs:Dictionary = new Dictionary();
public function map( voClass:Class, viewClass:Class):void{
_viewsByVOs[voClass]=viewClass;
}
public function createView(vo:NodeBase):INodeView{
var voClass : Class = vo.constructor as Class;
return new (_viewsByVOs[voClass] as Class)(vo);
}
}
//ConfigureNodeViewFactoryCommand
[Inject]
public var nodeViewFactory:INodeViewFactory
public function execute():void{
nodeViewFactory.map(VideoNode,VideoNodeView);
nodeViewFactory.map(Game1Node,Game1NodeView);
}</code>
</pre>
<p>Obviously you'd need to add a check to see whether the VO class
is mapped and otherwise throw an error.</p>
<p>I don't know whether architecturally this is the best approach,
I'd need more context to be able to judge that.</p></div>creynderstag:robotlegs.tenderapp.com,2009-10-18:Comment/268530282013-05-29T03:53:21Z2013-06-01T08:53:55ZSome kind of mapping betwen VO and View <div><p>It almost feels like the factory is a run around the Commands
and mapping mechanism.</p>
<p>When you reach a VideoNode, a NodeEvent.VideoNode fires and
HandleVideoNodeCommand executes. That command knows its duties:
setup a video player view to play a video and update the game UI
accordingly (like pause gameplay and the update loops). Once that's
completed, a state machine or some type of "next step" model makes
sure the appropriate action is executed, like going to the next
node in the tree or resume gameplay on a level etc...</p>
<p>You can than use Command Mapping and View Mapping to handle
temporary logic requirements. Like map all ForkStep to
ForkStep3View after this point.</p>
<p>Hope that makes sense!</p>
<p>Cheers,</p>
<p>J.</p></div>Jerome Maurey-Delaunaytag:robotlegs.tenderapp.com,2009-10-18:Comment/268530282013-06-25T09:33:00Z2013-06-25T09:33:00ZSome kind of mapping betwen VO and View <div><p>Closing this for now. You can re-open the thread, if need
be.</p></div>Ondina D.F.