Flashuser

  • Pin It

PureMVC – A Multiplatform Framework

As of late I started to do some research and make a list of the most popular open-source frameworks used in Flash/Flex/AIR development. But, unlike my previous posts, today I’m writing about a far more general framework: PureMVC.


The PureMVC project began in November 2006 and its purpose was to deliver a simple framework that enables quick implementation of rich client applications based upon the classic Model, View and Controller concept. I sad earlier that this framework is more complex because, originally it was implemented in ActionScript 3 for use with Adobe Flex, Flash and AIR, but in time has expanded and now allows development on a wide variety of platforms. PureMVC is being ported in several languages such as: C#, JavaScript, Java, PHP, Python, Ruby.

The framework has two versions that are supported with reference implementations Standard and MultiCore. “In short, the Standard Version provides a simple methodology for separating your coding interests according to the MVC concept. Beyond that, the MultiCore Version allows multiple PureMVC applications to run within the same virtual machine, modular programming.”

PureMVC implements a different concept in contrast with the standard MVC design pattern. The Model, View and Controller are implemented as Singleton classes:

  • The Model caches named references to Proxies, which expose an API for manipulating the Data Model (including data retrieved from remote services).
  • The View primarily caches named references to Mediators, which adapt and steward the View Components that make up the user interface.
  • The Controller maintains named mappings to Command classes, which are stateless, and only created when needed.

There is a fourth class, the Façade, that initializes and caches the Core actors (Model, View and Controller), and provides a single place to access all of their public methods. It acts as a communication bridge throughout the application. These classes are referred to as the Core Actors.

The framework has a Publish/subscribe-style Observer notification system and the communication is being done through this scheme rather than AS3 Events, which is understandable considering the whole group of languages that’s covering.

The differences between the Standard and MultiCore version, like the name underlines it is that the second one uses independent program modules each with their own independent PureMVC ‘Core’. And instead of Singleton classes there are Multitons(stores a map of instances). Each Core is referenced by an associated Multiton Key.

This project has a well developed documentation containing: source code freely available, complete API documentation, conceptual and UML Diagrams and plenty of demos show the basics and demonstrate best practices.

Conclusion

Because the amount of information about PureMVC is vast I tried to be as succinct as possible. Like most of the MVC frameworks, pureMVC has some good points and some bad ones. But the fact that it’s trying to be general and reach different platforms can be an issue. I am just saying that the generalization of this framework can make it mediocre in some way.

For a deep insight of this framework and its documentation check the PureMVC site.

Author: Alin

Passionate about web and graphic design, photography and climbing. Follow me at Twitter , Facebook and Google+

  • http://puremvc.org Cliff Hall

    “But the fact that it’s trying to be general and reach different platforms can be an issue. I am just saying that the generalization of this framework can make it mediocre in some way.”

    What do you expect an MVC framework to do for you that’s not mediocre?

    It’s like separating your laundry. If you don’t do it, you get fuzzy bedsheets because you washed your towels with them. Or your colors run on your whites. But you still have to do laundry (unless you have a butler), so you separate. It is the same with MVC.

    PureMVC was created specifically for use with Flex and AIR. That’s what I do, and I needed a good framework to use in my everyday job.

    It’s just that before creating it, I decided to use only proven design patterns and the most common language features, so that it would conceivably be portable to Tamarin (the supposed next version of JavaScript that was supposed to be ActionScript-like). I reasoned that Tamarin users would need a framework, too.

    Well Tamarin never happened, but lots of other people found that they could easily port PureMVC to their platforms/languages.

    So, what do you know, a tiny amount of foresight paid off. But I didn’t intentionally try to make it so vanilla it would port to every platform in the universe. It just turns out that doing MVC separation with the handful of patterns I used is something so simple you can do it anywhere.

    -=Cliff>

  • http://www.brianwiltshire.net Brian

    It’s a great framework !! And yes the foresight paid off in a major way !