Sunday, June 29, 2003

How to build a Flash app easily using the the Model-View-Controller (MVC) pattern.

The MVC pattern specifies that your application should be divided into three main pieces: the model which handles your application's data, the view which handles the visual interface, and finally the controller which handles user input.

Each of the pieces are independent, so they can be both tested on their own or reused in some other application.

The model of an application consists of the applications data and methods to retrieve and modify that data. For example, in an address book application the model would hold all of the data in the address book and provide methods to add, remove, and edit those addresses.

View and Controller

The view is what the user sees and interacts with, and the controller is which handles user input—for example, validation).

Just like you don't start installing light switches until after the foundation is poured, you shouldn't start this step until after you model is done. The reason for this is because any change to your model could potentially require you to rewrite your view and controller code.

The point of the view is to just provide the GUI, not manipulate it or handle user input

Building an application is a lot like building a house. Both are complex tasks that take a lot of planning. However, by following a few basic steps like those outlined above, you can break down the process into manageable pieces


Post a Comment

<< Home