Separating your data model from your view

To cleanly separate the user interface, application-specific data, and data services, you can use Flex data models that store data between controls and data services. This type of three-tier design is applicable to both input data and data service results.

When you plan an application, you determine the kinds of data that the application must store and how that data must be manipulated. This helps you decide what types of data models you need. For example, suppose you decide that your application must store data about employees. A simple employee model might contain name, department, and e-mail address properties.

A Flex data model is an ActionScript object that contains properties that you use to store application-specific data. You can use a data model for data validation, and it can contain client-side business logic. You can define a data model in MXML or ActionScript. In the model-view-controller (MVC) design pattern, the data model represents the model tier.

You can define a data model in an MXML tag, ActionScript function, or an ActionScript class. A model written in MXML is useful for rapid development and simple data storage, but it does not provide any additional functionality, and you cannot set the data types of the model's properties. You should use an ActionScript-based class if you want to set data types and provide methods for additional functionality. In general, you should use MXML-based models for simple data structures and use ActionScript for more complex structures and client-side business logic.


Version 1.5

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00002153.htm