Structuring Flex applications with the Swiz frameworkSpreker:  Jamie Craane
AgendaPresentationpatternsSwizQ&A
PresentationPatternsAutonomous viewPresentation ModelCode BehindModel View PresenterModel View ControllerAnd many more…
Autonomous viewView
Code BehindViewMXMLCode-behindEventhandlersData Model
Model View PresenterUses contract to read/write view dataViewPresenterRead/writemodelModel
Presentation ModelViewPresentationmodelModel
Model View ControllerResponds to user eventsViewControllerUpdatesmodelModelNotifies view
MVCViewModelServicedisplayupdateupdatemediatorupdateinvokesinvokesinvokesController
Model: Representing StateRepresentsclient state
[Bindable] : dispatcheseventon state changesessionuserpersonListtaskListselectedPerson
View: Presentation and InteractionViewModelReferencespersonlisttaskdetailsNotifiesPresents model to the user
Responds to model changes, ({} databinding)
Responds to user actions, (Declarativeeventhandling)
MostlyMXMLController: ExposeActionsUser-initiatedactions
Invokes services
Updates modelViewControllercallServiceInvokeModelUpdates
Service: EncapsulatesbackendsServicesPersonServiceTaskServicePersonServiceMockService callsremotedestinations
HttpServiceorRemoteObject (ie. BlazeDS)
Returns anASyncToken
Logical place forstubsMediators: update viewUser-initiatedactionsUpdates viewUpdates model (ifneeded)MediatorInterfaceViewcallViewUpdatesModelUpdates
SwizMicro architecture and Dependency Injection framework
MircoArchitectureFramework“Enables, but not restricts, in the implementation of an application following any given architecture”
Swiz in a nutshellDependency InjectionEvent MediationUtilitiesServiceHelperGlobal exception handlerAnd more…MetaData processors
DependencyInjection 1How can a given object obtain a reference to another object?
DependencyInjection 2Object AObject BDepends on
DependencyInjection 3Object ADI frameworkObject BObject AObject BApplicationContext
Dependencyinjection 4[Inject]public var userController:UserController;<?xml version="1.0" encoding="utf-8"?><swiz:BeanProvider	<controller:UserController/></swiz:BeanProvider>
Dependencyinjection 5Typically inject by typeSpecify Bean ID if necessaryWorks with interfaces and inheritance
WhyDependencyInjection?Removes dependencies on concrete implementationsNo ServiceLocatorEasy to see dependencies
EventMediationdispatcher.dispatchEvent(new TaskEvent(TaskEvent.SAVE_TASK_SUCCESS, true));[Mediate(event="TaskEvent.SAVE_TASK_SUCCESS")]publicfunction saveTaskSuccess():void {  this.closeTaskDetailsWindow();  taskController.retrieveTasks();}

Structuring your flex application with swiz