Difference between revisions of "MVC"

From Organic Design wiki
(See also: Ext JS)
m
 
Line 18: Line 18:
 
== Connection to the philosophy ==
 
== Connection to the philosophy ==
 
{{stub}}
 
{{stub}}
 
== ExtJS ==
 
[http://www.sencha.com/products/extjs Ext JS 4] comes with a new application architecture that not only organises your code but reduces the amount you have to write.
 
 
Our application architecture follows an MVC-like pattern with Models and Controllers being introduced for the first time. There are many MVC architectures, most of which are slightly different from one another. Here's how we define ours:
 
*Model is a collection of fields and their data (e.g. a User model with username and password fields). Models know how to persist themselves through the data package, and can be linked to other models through associations. Models work a lot like the Ext JS 3 Record class, and are normally used with Stores to present data into grids and other components
 
*View is any type of component - grids, trees and panels are all views.
 
*Controllers are special places to put all of the code that makes your app work - whether that's rendering views, instantiating Models, or any other app logic.
 
 
The [http://dev.sencha.com/deploy/ext-4.0.2a/docs/index.html#/guide/application_architecture ExtJS MVC guide] takes you through creating a very simple application that manages User data. By the end you will know how to put simple applications together using the new Ext JS 4 application architecture.
 
 
The application architecture is as much about providing structure and consistency as it is about actual classes and framework code. Following the conventions unlocks a number of important benefits:
 
*Every application works the same way so you only have to learn it once
 
*It's easy to share code between apps because they all work the same way
 
*You can use our build tools to create optimized versions of your applications for production use
 
  
 
== See also ==
 
== See also ==

Latest revision as of 19:30, 17 September 2011

Glossary.svg This page describes a concept which is part of our glossary

Model–View–Controller (MVC) is an architectural pattern for software development. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).

For example, the same domain logic should be able to be used to design applications for desktops, mobile devices, or even to be implemented with diaries, inboxes, forms and other paperwork. Since the domain logic is independent of specific technologies, it's possible to build any application or organisation's domain logic from a very basic Foundation Ontology.

The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.

The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.

The controller receives input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.

An MVC application may be a collection of model/view/controller triads, each responsible for a different UI element. The Swing GUI system, for example, models almost all interface components as individual MVC systems.

MVC is often seen in web applications where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) which contain the business rules and know how to carry out specific tasks such as processing a new subscription, and which hand control to (X)HTML-generating components such as templating engines, XML pipelines, Ajax callbacks, etc.

The model is not necessarily merely a database; the 'model' in MVC is both the data and the business/domain logic needed to manipulate the data in the application. Many applications use a persistent storage mechanism such as a database to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model. Models are not data access objects; however, in very simple apps that have little domain logic there is no real distinction to be made. Active Record is an accepted design pattern which merges domain logic and data access code - a model which knows how to persist itself.

Connection to the philosophy

Cone.png This article or section is a stub. Stubs are articles that have not yet received substantial attention from the authors. They are short or insufficient pieces of information and require additions to further increase the article's usefulness. The project values stubs as useful first steps toward complete articles.


See also