Wednesday, June 24, 2015

MVC

Controllers:

A controller built using the MVC should

 

•             Contain the logic required to initialize the scope

 

•             Contain the logic/behaviors required by the view to present data from the scope

 

•             Contain the logic/behaviors required to update the scope based on user interaction

 

The controller should not

 

•             Contain logic that manipulates the DOM (that is the job of the view)

 

•             Contain logic that manages the persistence of data (that is the job of the model)

 

•             Manipulate data outside of the scope

 

Views:

•             Contain the logic and markup required to present data to the user

 

Views should not

 

•             Contain complex logic (this is better placed in a controller)

 

•             Contain logic that creates, stores, or manipulates the domain model

 

Models:

•             Contain the domain data

 

•             Contain the logic for creating, managing, and modifying the domain data (even if that means

 

executing remote logic via web services)

 

•             Provide a clean API that exposes the model data and operations on it

 

The model should not

 

•             Expose details of how the model data is obtained or managed (in other words, details of the

 

data storage mechanism or the remote web service should not be exposed to controllers and views)

 

•    Contain logic that transforms the model based on user interaction (because this is the

 

controller’s job)

 

•             Contain logic for displaying data to the user (this is the view’s job)

 

 

No comments:

Post a Comment