Modern websites comprise, generally, of three main functions which combine to provide an interactive and effective CMS.

  • Model – information management and business logic
  • View – presenting information to the user
  • Controller – dealing with user input and carrying out requests

This Model, View, Controller architecture is known as MVC. Within the context of a typical website usually breaks down as follows:

  • Model – Database storage and management scripts, ensuring consistency and performance
  • View – Template system including themes, styling and other files associated with the visual representation
  • Controller – The scripts that handle user requests, interacting with the Model to effect change or extract data and presenting this to the end-user via the View.

mvcFor example, lets look at an e-commerce store, and you are a visitor who has seen a particularly fetching hat. You click the link that adds the hat to your shopping cart.

  1. Your browser sends a http request that specifies the hat and that it should be placed in the shopping cart. This request arrived at the application’s Controller.
  2. The Controller checks the data to ensure it is valid (i.e. not malformed) and tells the Model to store this data in your customer account (or temporary session).
  3. The Model checks that such a product exists in the product catalogue and updates the database to store the updated shopping cart information.
  4. The database reports the result of the update as successful.
  5. The Model reports to the Controller that the shopping cart was updated.
  6. The Controller pulls the correct template/style/formatting information from the View.
  7. The Controller integrates the information returned from the Model with the View.
  8. The Controller updates the user interface (e.g. the shopping cart icon now shows an extra item).

This is a very simplified example, and many other things actually happen when something is added to a shopping cart, but hopefully it explains the basic concept of the MVC architecture.


No comments yet.

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.