Prabhu Sunderaraman, Software Mentor, DuraSoft
Flex is one of the really rich mechanisms for creating Rich Internet
Applications, which has grown very rapidly over last few years. Plenty of
applications that have charts and reports are implemented using Flex.
Working with Flex can get really clumsy if you don't follow a proper design
to layout various entities in your applications. The code in MXML files tend to
get too crowded and unmanageable after sometime. Making changes and
incorporating new functionalities becomes tedious and time consuming. The best
way to handle this issue is to remove the ActionScript code out of the MXML
files. The evergreen Model-View-Controller (MVC) pattern can be used to create
maintainable Flex applications. MVC pattern in Flex focuses on separating the
ActionScript code and the UI elements used in MXML. The MVC pattern can either
be hand-tossed or implemented using standard frameworks in your applications.
Hand tossing the MVC pattern has its own pros and cons. It gives complete
control of the flow in the application, but can get very difficult as the
application grows. There are a number of Flex MVC implementations available
that can be used in your applications. These frameworks bring in a discipline in
the way Flex applications are created. A list of some of the well-known Flex MVC
frameworks are given below.
Direct Hit! |
Applies To: Flex Developers |
Each framework has its own advantages and disadvantages. Based on the
complexity of the application, one of these frameworks can be chosen to
implement MVC.
Pure MVC: http://puremvc.org. Pure MVC is an open source
implementation of MVC pattern and one of the widely used. It provides
traditional set of model, view and controller classes. It is built using the
popular command, singleton, Façade and Observer design patterns.
Cairngorm http://opensource.adobe .com/wiki/ display/cairngorm/ Cairngorm.
Cairngorm is Adobe's open source lightweight MVC implementation. It uses the
popular J2EE patterns like ServiceLocator, BusinessDelegate in its
implementation. Similar to the Pure-MVC framework, Cairngorm also has its own
set of controller and command classes.
Mate: http://mate.asfusion.com/. Mate is the MVC framework based on
events and dependency injection. It provides facilities to handle events in a
customized manner. The data that is processed or fetched from different sources
can be injected into different parts of the application.