2007 Adobe Systems Incorporated. All Rights Reserved.
PureMVC: Next Steps & Conclusion Adobe Flex 3 Microarchitectures Series
Samuel Asher Rivello Principal, RivelloMultimediaConsulting.com (RMC) Certified Designer & Developer (Adobe Flash)
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC
Next Steps • Recap Today’s “Hello Google” Project
• 10 Tips for Using PureMVC
• PureMVC Alternatives
• PureMVC.org Website
• References, SourceCode
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: Recap
The Framework • A framework is a collaborating set of design patterns
• Learning a framework is a very worthy investment to empower your team to build bigger, better projects
• PureMVC is a framework separates M,V,C logic in your app to enable teamwork, maintainability, and extensibility
• UI, VO, and actors of PureMVC shown in diagram below
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: Recap
Hello Google Sample App • Silly, but simple & complete example using PureMVC
• The user clicks a Button which populates a TextField with text from Google’s homepage.
• Entire Interaction from UI Button click to server call/response to update UI TextField summarized in diagram to right
TextField
Button
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: 10 Tips – 1 Through 5 1. Think in (Pure)MVC
• How do I start using PureMVC? Short answer: Just think in MVC! 1. Proxies = Model
2. Mediator and View Components = View 3. Commands = Controller
2. Create an API for View Components • A View Component might be a standard UI component (e.g. DataGrid) or a custom
component (e.g. a world within a game) or whatever. Don’t use its public methods directly. Use its Mediator as a wrapper to create an API.
3. Use one Mediator for multiple View Components • To closely coordinate more than one View Component, use just one Mediator to control
them all. 4. Let Events bubble up
• Bubble events from the nested children of a view component up to the mediator. 5. Communicate using Noti!cations as often as possible
• It’s a bad practice to change a Proxy (Model) from a Mediator (View) directly without using a Command (Controller).
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: 10 Tips – 6 Through 10
6. Use Commands / MacroCommands as often as possible
• Once code is in a command, simply send the appropriate noti!cation from anywhere to repeat its execution.
7. Use Remote Proxy to send and receive server-side data
• This is HUGE! If the server’s API changes, you will only have one area of your code to change. Very convenient encapsulation.
8. Unregister unused Mediators
9. The Power of VO’s (Value Objects)
• View Component has no access to the Model data directly.
10. Practice, Practice, Practice
• Do a few demos from scratch to learn the basics
• Build time into your !rst production project to learn-as-you-go!
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC
When to Use PureMVC (or a Framework in General) • When scalability and maintainability are more important than rapid execution
• When the project feels more ‘application’-like (Many UI controls / Discrete business logic) than ‘game’-like
• Medium to Large Projects (> 100 Man hours)
• Team Projects ( > 2 Developers)
• Long Term Projects (> v1.0 in discussion)
My Opinion: Once expertly trained on PureMVC teams work faster with PureMVC than a custom solution.
• Faster Architecture Stage
• Faster Implementation (Debatable)
• Faster Meetings / Discussions
• Faster Development of Post-v1.0 Features (By Far)
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: Alternatives
Flash Platform Frameworks • Cairngorm - http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm
• Mate - http://mate.asfusion.com/
• Swiz - http://code.google.com/p/swizframework/
• Others - ARP, MVCS, Flest, Model-Glue: Flex, ServerBox Foundry, Guasax, Slide, and many many more…
• Comparison of Frameworks
• http://puremvc.org/content/view/43/98/
• http://www.adobe.com/devnet/"ex/articles/"ex_framework.html
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: vs. Cairngorm: The Very Basics
In Cairngorm, typically you:
• De!ne the ModelLocator class as a Singleton.
• Add properties to it.
• Fetch the ModelLocator Singleton at various places in the View by calling its getInstance method.
• Bind to its properties.
In PureMVC, you:
• De!ne proxies to hold the data
• Register them with the Model, typically via the Facade
• Retrieve the Proxies elsewhere with Commands or Mediators
• Set the data on the View Components with Mediators
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: vs. Cairngorm: The Major Parts
PureMVC
Model View Controller Command Facade Proxy Mediator Noti!cation
More Info: http://geekglue.blogspot.com/2007/10/cairngorm-vs-puremvc-quick-comparison.html
Pros & Cons: http://robsondesign.com/demo/framework_comparison/
Cairngorm
Model View Controller Command CairngormEvent Delegate Service
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: Website
PureMVC.org • Downloads
• Documentation
• Examples, Showcase, Forums, News
• Plug-in Utilities
• State Management
• Startup App Loading Management
• Much, Much More…
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: QA
Any Questions on The Topics Covered?
Section 1: De!nition and Bene!ts of PureMVC
Section 2: PureMVC Applied • Adding PureMVC to your project
• Using my PureMVCTemplate
• Building “Your First Project”
Section 3: Next Steps, QA, & Conclusion • 10 Tips for PureMVC
• Comparison to Other Frameworks
• References & Links
2009 Rivello Multimedia Consulting. All Rights Reserved.
PureMVC: References & Thank you!
REFERENCES
FULL DOCUMENTATION TO TODAYS TALK • Contact 360|Flex
ARCHIVE OF TODAYS VIDEOS • Contact 360|Flex
MY OTHER PRESENTATIONS • See ‘Blog’ on RMC link above. (Post a Comment!)
PUREMVC • http://www.puremvc.org
• ADOBE FLEX 3 • http://www.adobe.com/products/"ex/
SPECIAL THANKS!!!
PUREMVC AUTHOR
• Cliff Hall
• http://www.puremvc.org
• Email & Contact – See Website
SPEAKER
• Samuel Asher Rivello| Principal, RivelloMultimediaConsulting.com (RMC)
• RMC Services: Software Architecture, Consulting, Development, & Training
• Specializes in PureMVC Architecture
• Business Cards Available
PureMVC on the EDGE!
• Article Published: “An introduction to PureMVC for Adobe Flash and Flex” on Adobe’s EDGE newsletter ahttp://www.adobe.com/newsletters/edge/december2008/articles/article6/)