7 Replies Latest reply on Jun 18, 2011 5:03 AM by Wrataxas

    MVC with MXML and Flex

    Wrataxas Level 2

      I want to use Model-View-Controller design and I want to set up my views using MXML.  I'd like to use the "passive view" variant, where there is as little code as possible in the view; you put it all in the controller.  One reason for this is because views are hard to unit test, so you put the logic where it is easy to test.

       

      So I will have all these controllers written in ActionScript and all these views in MXML and how do the controllers find the views?  It could be a pretty deep tree of views and it doesn't make sense for each controller to know how to walk the tree to find its corresponding view.

       

      One thought I had was to have each view register itself in a dictionary that the controllers could interrogate.  Not sure I like that approach though.  Does anyone have any other suggestions?

       

      Thanks.