Presentation Model pattern with Flex and Swiz FrameworkPiotr Walczyszyn | Platform Evangelist
About me2Piotr WalczyszynPlatform Evangelisthttp://riaspace.comhttp://twitter.com/pwalczyszyn
3Presentation Model
Presentation Model4Presentation ModelViewState & LogicProvides Model dataDecoupled from ViewObserves Model dataUpdates Model dataCoupled with PM
Presentation Model: Main.mxml5Main.mxmlMainPMcurrentState:String<views:MainView />model +1<swiz:Swiz />
Presentation Model: MainView.mxml6MainView.mxmlcurrentState=“{model.currentState}”UsersListPMusers:ArrayCollection<views:UsersListViewincludeIn=“USERS_LIST_STATE” />AddUserPMuser:UsercreateUser():void<views:AddUserViewincludeIn=“ADD_USER_STATE” />model +1model +1
Presentation Model:UsersListView.mxml7UsersListView.mxml<s:ListdataProvider=“{model.users}” />
Presentation Model:AddUserView.mxml8AddUserView.mxml<s:TextInput text=“@{model.user.name}” />
9Swiz
Swiz IntroFramework for FlexLightweight & flexibleDoesn’t enforce any design patterns, project layout or inheritanceDecoupled from your application code10
Swiz FeaturesInversion of Control / Dependency Injection[Inject]Event handing and mediation[Dispatcher], [Mediate]Handling bean life cycle[PostConstruct], [PreDestroy]Simplifies remote service callsServiceHelper, MockDelegateHelperChaining APIEventChain, CommandChainCustom Metadata Processors[URLMapping], [MediateSignal], [Resource], [Logger], [Bind]11
Swiz Linkshttp://swizframework.org/http://swizframework.jira.com/wiki/display/SWIZ/Home12
13Demo
Full Class Diagram14
Presentation Model pattern with Flex and Swiz framework

Presentation Model pattern with Flex and Swiz framework

Editor's Notes

  • #5 PM is a variation of MVC design pattern.Key principals:State is in the presentation modelLogic is in the presentation modelView observes the model and updates accordinglyThe view “knows” about the presentation modelThe presentation model does not “know” about the view