Titanium Alloy: MVC architechture

Introduction

The Alloy framework of Titanium helps us to organize our applications into Model, View and Controller. It also provides the built-in support for Backbonejs and Underscorejs- JavaScript Library.

In this framework, the Model contains the data source, View(js) and style(tss) contains the UI part and Controller contains the business logic part of the application.

As shown in the above diagram, the controller updates the model and model notifies about every change being made by the controller in the data source with the updated data. With this updated data, the controller then updates the views created in the view part of the application, which when shown to the end user, he/she perform some action on views. These actions are again listened by the controller and reply back with proper operations.
So, based on the above explanation, we can define the MVC architecture as follows:
  • Controller
    • It contains all the business logic part of the application. 
    • It can send command to the model to perform the CRUD (Create, Read, Update and Delete) operations.
    • It can also send command to its associated views to change the views' presentation of the model(example lazy loading of listview, scrollview and tableview etc.).
    • It is defined in the JS file inside the controller folder of the alloy framework.
  • Model
    • It represents the data source of the application. It can be any of the following:
      • Data from web services
      • Data from SQL
      • Data from Local Storage
      • Data from App properties
    • It notifies its associated views to produce updated output sync with the data source.
    • It also notifies the controllers to change the available set of commands.
    •  It is defined in JS file inside the model folder of the alloy framework.
  • View
    • A view requests information from the model via controller that it uses to generate an output being represented to the user.
    • It is defined using XML and TSS files in views folder of the alloy framework.

Comments

Popular posts from this blog

श्मशान और ज़िंदगी

साथ

प्रेम