Pages

Tuesday, August 2, 2011

MVC Structure Basics, MVC Architecture, Joomla

For starters, MVC stands for Model, View, Controller. It is a programing structure used in developing web apps. This structure isolates the user interface and backend (i.e. database interaction from each other. A successful implementation of this lets developers modify their user interface or backend with out affecting the other. MVC structure also increases the flexibly of an application by being able to resuse models or views over again). Below is a description of MVC structure.
  • Model: The model deals with the raw data and database interaction and will contain functions like adding records to a database or selecting specific database records.
  • View: The view deals with displaying the data and interface controls to the user with.
  • Controller: The controller acts as the in between of view and model and, as the name suggests, it controls what is sent to the view from the model.
An example of a MVC structure approach would be for a contact form.
  1. The user interacts with the view by filling in a form and submitting it.
  2. The controller receives the POST data from the form, the controller sends this data to the model which updates in the database.
  3. The model then sends the result of the database to the controller.
  4. This result is updated in the view and displayed to the user.
This may sound like alot of work to do. But, trust me; when you’re working with a large application, being able to reuse models or views saves a great deal of time.

No comments:

Post a Comment