Tuesday 17 September 2013

MVC Design Pattern in AS3

“Model-view-controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC,

The model represents the information (the data) of the application and the business rules used to manipulate the data;
The view corresponds to elements of the user interface such as text, checkbox items, and so forth;
The controller manages details involving the communication to the model of user actions such as keystrokes and mouse movements.”

The MVC Design Pattern
Creates a separation of Class roles
Adds a clear and logical communication structure
Increases flexibility in larger applications
Model
    Handles data storage and retrieval (eg. Store character x position)
View
    Handles the display/communication (eg. Position character on stage)
Controller
    Handles most the of the application logic (eg. Get current x position)

MVC – basic structure
Each model can have multiple views
Each view has at least one matching controller
Creates a separation between form, content and action
The model becomes the base of the application




Sample Game:-

Aim:-

A Square with randomly changed color when button was pressed

Architecture:-


No comments:

Post a Comment