Framework Overview
with UML Diagrams
Learn to Build Robust, Scalable and Maintainable
Applications using PureMVC

Framework Overview
This document discusses the classes and interfaces of the PureMVCframework; illustrating their roles, responsibilities and collaborations
with simple UML (Unified Modeling Language) diagrams.
The PureMVC framework has a very narrow goal. That is to help you
separate your application’s coding concerns into three discrete tiers;
Model, View and Controller.
In this implementation of the classic MVC design meta-pattern, theapplication tiers are represented by three Singletons (a class whereonly one instance may be created).
A fourth Singleton, the Façade, simplifies development by providing asingle interface for communications throughout the application.
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 andsteward the View Components that make up the user interface.
The Controller maintains named mappings to Command classes, which arestateless, and only created when needed.
The Façade initializes and caches the Core actors (Model, View andController), and provides a single place to access all of their public methods.

AUTHOR: Cliff Hall <cliff@puremvc.org>
LAST MODIFIED: 3/05/2008

Façade and CoreThe Façade class makes it possible for the Proxies, Mediators andCommands that make up most of our final application to talk to eachother in a loosely coupled way, without having to import or work
directly with the Core framework actors.
When we create a concrete Façade implementation for our application,
we are able to use the Core actors ‘out of the box’, incidental to ourinteraction with the Façade, minimizing the amount of API knowledge
the developer needs to have to be successful with the framework.
The Core actors Model, View and Controller implement IModel, IViewand IController interfaces respectively. The Façade implements IFacade,which implements all the Core interfaces, by composition.
PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 2 of 14

3/5/2008 10:27 PM

Façade and Core

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 3 of 14

3/5/2008 10:27 PM

View, Mediators and View Components
The View class is implemented as a Singleton that caches and provides
access to concrete IMediator instances.

Mediators help us to create or reuse existing user interface
components without the need to imbue them with knowledge about
the PureMVC application they communicate with. Concrete Mediators
must implement the IMediator interface, usually by sub-classing theframework Mediator class.
View Components display data or accept user gestures. In a Flashbased application, they typically communicate with their Mediators
using Events and exposing some properties for the concrete Mediator
to inspect or manage. A Mediator connects a View Component with its
data and communicates with the rest of the system on its behalf.
When a concrete Mediator is registered with the View, it is queried as
to its Notification interests. It must return an Array of all the names of
the Notifications it wishes to be informed of.
Because it must implement the IMediator interface, the concrete
Mediator will have a handleNotification method. When it is registeredwith the View, an Observer instance is created and registered for each

Notification in the Array so that the Mediator's handleNotification
method is invoked whenever a Notification of interest to the Mediator
is sent.
The Mediator framework class implements INotifier and so has asendNotification method, which takes the parameters for a new
Notification, constructs the Notification and uses the Singleton IFacade
instance to send it.
PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the impliedwarranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 4 of 14

3/5/2008 10:27 PM

View, Mediators and View Components
The Mediator’s protected façade property is initialized to the registeredIFacade instance, and therefore the Mediator must be constructed after
you have initialized your Application's concrete Façade.

View

IView-instance : IView-mediatorMap : Array-observerMap : Array-SINGLETON_MSG : String+registerObserver(in notificationName : String, in observer : IObserver) : void+notifyObservers(in notification : INotification) : void+registerMediator(in mediator : IMediator) : void+retrieveMediator(in mediatorName : String) : IMediator+removeMediator(in mediatorName : String) : void+hasMediator(in mediatorName : String) : Boolean+View()+getInstance() : IView#initializeView() : void1*Mediator

IMediator
1+NAME : String-viewComponent : Object-facade : IFacade+getMediatorName() : String+setViewComponent(in viewComponent : Object) : void+getViewComponent() : Object+listNotificationInterests() : Array+handleNotification(in notification : INotification) : void+onRegister() : void+onRemove() : void+sendNotification(in notificationName : String, in body : Object, in type : String) : void+Meditator(in viewComponent : Object)

1

ViewComponent
1

1

IFacadeFacadePureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 5 of 14

3/5/2008 10:27 PM

Model, Proxies and Data Objects
The Model class is implemented as a Singleton that caches andprovides access to concrete IProxy instances.

Proxies help us to expose data structures and entity classes (and thedomain logic and services that support them) to our application in sucha way that they may be easily reused elsewhere, or refactored with aminimum amount of impact to the rest of the application.
We might use a concrete Proxy to simply manage a reference to a
local data object, in which case idioms for interacting with it might
involve synchronous setting and getting of its data.
A Proxy might also encapsulate the application's interaction with aremote service to save or retrieve a piece of data, in which case, one
might call a method or set data upon the Proxy and await a

Notification sent when the Proxy has retrieved the data from theservice.
The Proxy framework class implements INotifier and so has asendNotification method, which takes the parameters for a new
Notification, constructs the Notification and uses the IFacade Singleton
instance to send it.
Its protected façade property is initialized to the registered IFacade
instance, and therefore the Proxy must be constructed after you haveinitialized your Application's concrete Facade.

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 6 of 14

3/5/2008 10:27 PM

Model, Proxies and Data Objects

ModelIModel-instance : IModel-proxyMap : Array-SINGLETON_MSG : String+regsterProxy(in proxy : IProxy) : void+retrieveProxy(in proxyName : String) : IProxy+removeProxy(in proxyName : String) : void+hasProxy(in proxyName : String) : Boolean+Model()+getInstance() : IModel#initializeModel() : void1
*ProxyIProxy1+NAME : String-data : Object-proxyName : String-facade : IFacade+getProxyName() : IProxy+onRegister() : void+onRemove() : void+sendNotification(in notificationName : String, in body : Object, in type : String) : void+getData() : Object+setData() : Object

11

DataObject
IFacadeFacade1

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 7 of 14

3/5/2008 10:27 PMController and Commands
The Controller class is implemented as a Singleton that maintains amapping between Notification names and Command class references.
A Command may retrieve and interact with Proxies, communicate withMediators, or execute other Commands. Commands are often used toorchestrate complex or system-wide activities such as application
startup and shutdown.
When it is initialized (typically by an IFacade implementation), theController creates and registers with the View an appropriate Observer
instance for each Notification to Command mapping, such that when
any of the registered Notifications are broadcast, the Controller'sexecuteCommand method is called with the Notification.
WhenNotifications are broadcast by the View, the Controller
instantiates the appropriate Command class and calls the execute
method, passing in the Notification.
PureMVC includes two ICommand class implementations that you may
easily extend. Both implement INotifier, and so have a sendNotification
method and a protected façade property, initialized to the Singleton

IFaçade instance.
The SimpleCommand class merely has an execute method which iscalled with the Notification object.
TheMacroCommandclass

allowsyoutoexecute

multiple'subcommands' sequentially, each being created and passed theoriginal Notification on its execute method.

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 8 of 14

3/5/2008 10:27 PM

Controller and Commands
MacroCommand calls its initializeMacroCommand method from within
its constructor. You override this method in your sub classes to call theaddSubCommand method once for each Command to be added. You
may add SimpleCommands or other MacroCommands.

Controller

IController-instance : IController-view : IView-commandMap : Array-SINGLETON_MSG : String+registerCommand(in notificationName : String, in commandClassRef : Class) : void+executeCommand(in notification : INotification) : void+removeCommand(in notificationName : String) : void+hasCommand(in notificationName : String) : Boolean+Controller()+getInstance() : IView#initializeController() : void

MacroCommand

ICommand-subCommands : Array-facade : IFacade+execute(in notification : INotification) : void+sendNotification(in notificationName : String, in body : Object, in type : String) : String+MacroCommand()+initializeMacroCommand() : void+addSubCommand(in commandClassRef : Class) : void1«uses»

1
IFacade«uses»

FacadeSimpleCommand
ICommand-facade : IFacade+execute(in notification : INotification) : void+sendNotification(in notificationName : String, in body : Object, in type : String) : String
11
IFacadeFacadePureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 9 of 14

3/5/2008 10:27 PM

View, Observer and Notification
Proxies, Mediators and Commands communicate with each other in aloosely-coupled
Notifications.

andplatform-neutralwaybroadcast,

doProxies may
Notifications.

•Mediators listen for and may broadcast Notifications.

•Commands areNotifications.

byandnotbroadcasting•

triggeredbutby

maylistenfor

broadcastSince PureMVC applications may also run in a pure ActionScript
environment
without
theunderlying
flash.events.Event andEventDispatcher classes, the framework implements an Observer
notification scheme for communication between the Core actors andother parts of the system.
PureMVC employs the Observer pattern for this purpose. An IObserver
instance carries a reference to an object which wishes to be notified(the 'Notify Context'), and a method on that object to call when anINotification is broadcast (the 'Notify Method').
The View is responsible for managing the map of Notification names toObserver lists and for notifying all Observers when a Notification issent.

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 10 of 14

3/5/2008 10:27 PM

View, Observer and Notification

View

IView

-instance : IView-mediatorMap : Array-observerMap : Array-SINGLETON_MSG : String+registerObserver(in notificationName : String, in observer : IObserver) : void+notifyObservers(in notification : INotification) : void+registerMediator(in mediator : IMediator) : void+retrieveMediator(in mediatorName : String) : IMediator+removeMediator(in mediatorName : String) : void+hasMediator(in mediatorName : String) : Boolean+View()+getInstance() : IView#initializeView() : void1*Observer

IObserver-notify : Function-context : Object+setNotifyMethod(in notifyMethod : Function) : void+setNotifyContext(in notifyContext : Object) : void+getNotifyMethod() : Function+getNotifyContext() : Object+notifyObserver(in notification : INotification) : void+Observer(in method : Function, in context : Object)«uses»

Notification

INotification-name : String-type : String-body : Object+getName() : String+setBody(in body : Object) : void+getBody() : Object+setType(in type : String) : void+getType() : String+toString() : String+Notification(in notificationName : String, in body : Object = null, in type : String = null)

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 11 of 14

3/5/2008 10:27 PM

Interfaces
IFacadeIModel«interface»interfaces::IModel+regsterProxy(in proxy : IProxy) : void+retrieveProxy(in proxyName : String) : IProxy+removeProxy(in proxyName : String) : void+hasProxy(in proxyName : String) : Boolean

IView«interface»interfaces::IView+registerObserver(in notificationName : String, in observer : IObserver) : void+notifyObservers(in notification : INotification) : void+registerMediator(in mediator : IMediator) : void+retrieveMediator(in mediatorName : String) : IMediator+removeMediator(in mediatorName : String) : void+hasMediator(in mediatorName : String) : Boolean

IController«interface»interfaces::IController+registerCommand(in notificationName : String, in commandClassRef : Class) : void+executeCommand(in notification : INotification) : void+removeCommand(in notificationName : String) : void+hasCommand(in notificationName : String) : Boolean

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 12 of 14

3/5/2008 10:27 PMInterfaces
IProxyIMediator

ICommandINotifier

IObserver

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 13 of 14

3/5/2008 10:27 PM

Interfaces
INotification

PureMVC is a free, open source framework created and maintained by Futurescale, Inc. Copyright © 2006-08, Some rights reserved.
Reuse is governed by the Creative Commons 3.0 Attribution Unported License. PureMVC, as well as this documentation and any training materials or demonstration sourcecode downloaded from Futurescale’s websites is provided 'as is' without warranty of any kind, either express or implied, including, but not limited to, the implied
warranties of fitness for a purpose, or the warranty of non-infringement.
PureMVC_Framework_Overview_with_UML.doc

Page 14 of 14

3/5/2008 10:27 PM