MVC the Model-View-Controller Pattern

The time has come, I’m in need of a new portfolio website. I have started the planning stages of my interactive application architecture. I have chosen to use the MVC pattern vs the MVP (Model-View-Presenter) or the PAC(Presentation-Abstraction-Control). I have been using the MVC for the past 3 years and I have acquired a great admiration for it.

Well what is a MVC pattern?
In a nutshell the MVC pattern is a methodology for separating the concerns of an application’s data, presentation, and user input into specialized components.

The Model represents the state, structure, and behavior of the data being viewed and manipulated by the user. The Model contains no direct link to the View or Controller, and may be modified by the View, Controller, or other objects with the system. When notification to the View and Controller are necessary, the Model uses the Observer Pattern to send a message informing its dependents that the data has changed.

The View is the visual representation of the Model and is comprised of the screens and widgets used within an application. The View’s responsibility can be seen as primarily dealing with output while the Controller’s responsibility can be seen as primarily dealing with input. It is the shared responsibility of both the View and the Controller to interact with the Model.

The Controller is a component which responds to user input such as data entry and commands issued from a keyboard or mouse. The Controller interacts with the Model as the result of responding to user input, while the View interacts with the Model as the result of updates to itself. Both may access and modify data within the Model as appropriate.

Why would I use a design pattern for my personal portfolio versus using the procedural methodology?

Well, the bottom line is that MVC maybe overkill for my small application. But by forcing myself to isolate the model, view, and controller components, it really makes me rethink my application and put a lot of thought into the parts and how they interact. Its also a good exercise that I will benefit from in the long run.

I started my portfolio project by looking into established MVC frameworks available to the public.
A day and a half later I decided to study up on PureMVC.
PureMVC is not tied to ActionScript, in fact it has been ported to eleven different languages to date. This could be useful if I need to port my application to another language. PureMVC seems to be popular and has a great adoption rate by other Flash/Flex developers.
Here are a few benefits to using PureMVC as my framework.

  • It has great documentation, samples, support and a thriving community, it’s easy to use and easy to extend.
  • It just works. All designs patterns used are described in the classic “Gang of Four” book – Design Patterns: Elements of Reusable Object Oriented Software by Erich Gamma.
  • It facilitates loosely coupled application architecture Publish/Subscribe–style observer notifications to provide scalability, maintainability, and portability.

    There is one drawback it has a STEEP learning curve.


    The Model, View and Controller are Singletons with access provided through a central Facade which is the entry point and hub of the application. Models are implemented as Proxies, controllers as Commands and views as Mediators. Communication between object is mostly done using PureMVC’s own Notification system rather than AS3 Events – this is odd, but makes sense since PureMVC has been ported to different languages which do not support AS3 Events. I haven’t yet delved into the code to see if AS3 events are being used under the hood.

    *Note that AS3 events are still used on the visual side of things (i.e. between the Views and their Mediators).

    I have so far noticed that I have been typing quite of bit code to make things happen, my initial thoughts are that this seems to be a general theme throughout PureMVC. I’ll be updating this post once I have a working portfolio to share.

    Be Sociable, Share!
  • Coding Color | 2009 All Rights Reserved.