Introducing PureMVC

For many Flash Developers out there, you have probably heard about Design Patterns, one of which would definitely be the popular Model View Controller [MVC] architectural pattern.

For those that are not familiar with the pattern, suffice to say that this pattern, prescribes a way to separate, the data, business logic, and presentation layer, of an application/microsite in an organized manner.

If implemented correctly, this would provide a more structurally sound code that is robust, and able to better accommodate future changes to the program, even with some unforeseen ones.

The MVC pattern is a powerful pattern, but for those that have just started Design patterns or OOP, it can be bit more than they can chew. One of the reasons being how one should set up the connections between the Model [data], View [presentation layer] and the Controller [business logic]. Fortunately, the flash community, has created a few frameworks to solve this problem, the one that I will be focusing on today is the PureMVC framework, which can be found at puremvc.org.

The PureMVC framework consists of the following main participants:

  • ApplicationFacade: The skeleton, which the other participants are registered to, its responsibility is to provide a formal way for them to communicate with each other,
  • ProxiesData sources: These can be xml, http requests, or frontend data, like what section the user is currently on.
  • Commands: Business logic that carries out tasks, other than presentation logic.
  • Mediators: Classes, which control the Presentation of the Application/Microsite.

The PureMVC handles communication via Notifications, which is actually the EventListener System of AS3, but with its own twist.

Each participant with the exception of the ApplicationFacade, would register with the Notifications they will be broadcasting, as well those that they would like to receive with the ApplicationFacade, instead of directly registering with the other participants.

What this does is that it decouples the participants from each other, allowing the developer to easily make changes, by substituting modules, which function differently, but send the same notifications.

With careful planning, this will lead to a more robust design that gracefully accepts changes in functionality that occur over the lifetime of an application/microsite, especially after the initial application/microsite has been launched.

Hopefully this long post, has provided an interesting read, if so the next time you need to develop a scalable website or application, look up frameworks such as PureMVC, to see how they can ease your development.

If you are interested to read up more on this topic, the following links to presently available frameworks will be useful.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License