Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Why do we need a Model, View, Controller architecture?

In the very early days of the web, it was a source of data - with files of marked up text (in HTML) being sent out to a browser program by a server running on a central computer. Requests to the central server were made in http (Hypertext transfer protocol), and the responses were translated by the browser program to come up with an appropriate screen display. And the fundamentals of this exchange, and of HTML, remain surprisingly little changed to this day.

"Can we include pictures please?" - just about the first update, and the browser makes requests for further data files - this time not text, but images in a format such as .gif or .jpg. And other add-in file type come later, such as Java Applets, Flash movies, downloads, JavaScript, and style sheets. That's still using http for transferring the data; it's simply a different type of data as far as the web server is concerned, and it's sent out with a header to tell the browser what it's getting, so that the browser can work out what do do with it.

Server side programming - the Common Gateway Interface"Can we send the output from a program, rather than a plain file from the server, please?". Scenario (one of ours). We can run an onsite course in the UK in any one of 127 different postcode areas. In any one of 32 counties in Ireland. In any one of 25 other countries in the EU ... and many other countries too. Onsite courses can last from 1 to 5 days, and can have any number of delegates up to 15. If there was an individual web page for each possible quotation, that would be over 10,000 separate web pages, so we can do that via a program which generates the HTML dynamically. The first way that such programs talked to the web server was through CGI (the Common Gateway Interface) as this allows established languages that predate the web to be used, taking inputs from (in essence) the keyboard, the command lin and environment variables which are, within CGI, taken over by the web server to feed in data that the user has entered onto a form.

Server side programming - program elements within HTML"But I don't want to write a whole program - there are only a couple of things that change within a page!". It did seem rather messy to write a program to output what's mostly static text for applications like our quotation system. So in addition to CGI, many web servers support programming languages embedded within the HTML of the browser. I call this "HTML++" during our courses; it's the model used for languages such as PHP.

"I need to be able to chain together a series of pages for a user - to turn a simple form based program into a complete application". You can do so using CGI, or using HTML++. You'll need to remember which user is which, possible through hidden fields but much more commonly done using cookies. A cookie is a piece of data that's send out within an http response in addition to the regular content, and is then returned to the server with each subsequent request. In effect, the user is saying "it's me again". The programs on the server do need to manage the storage of data between form submissions by the same user, and to relink that data back to the continuing application. They also need to be able to manage sessions which the user has abandoned, and they need to be able to handling the echoing out of forms which weren't filled in correctly so that the user can make amends. Some of this is supported within the languages, or via optional add in modules, as it's such a common requirement.

"But my application is getting all confused and messy with all this stuff!!!". Yes - you can do so much with what I've described above, but the program elements really need some sort of structure to them to help ease the development, testing, use, maintenance and reuse. And that's where the "MVC" model comes in.

Please read on ... via my follow up Model, View, Controller article.

(written 2012-02-25, updated 2012-03-03)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Q915 - Object Orientation and General technical topics - Principles of Model - View - Controller
  [4691] Real life PHP application using our course training MVC example - (2016-06-05)
  [4641] Using an MVC structure - even without a formal framework - (2016-02-07)
  [4527] Hello Flask world / Python web micro framework - (2015-10-11)
  [4391] Refactoring Perl applications to give them a rosy future - (2015-01-11)
  [4320] An example of Model-View-Controller techniques in a Perl / CGI script - (2014-11-20)
  [4114] Teaching CodeIgniter - MVC and PHP - (2013-06-12)
  [4066] MVC and Frameworks - a lesson from first principles in PHP - (2013-04-19)
  [4010] Really Simple Rails - (2013-02-17)
  [3919] What is a web framework? - (2012-11-10)
  [3705] Django Training Courses - UK - (2012-04-23)
  [3454] Your PHP website - how to factor and refactor to reduce growing pains - (2011-09-24)
  [3237] Using functions to keep look and feel apart from calculations - simple C example - (2011-04-09)
  [2612] The Model, View, Controller architecture (MVC) - what, why and how. - (2010-02-01)
  [2199] Improving the structure of your early PHP programs - (2009-05-25)
  [687] Presentation, Business and Persistence layers in Perl and PHP - (2006-04-17)

R202 - Ruby on Rails
  [4013] Web Frameworks - nested templates - (2013-02-22)
  [3780] Ruby of Rails - cleanly displaying model data in the view - (2012-06-23)
  [3779] Adding validation to form entries and sticky fields - Ruby on Rails - (2012-06-23)
  [3778] Providing a form to allow the user to add data to the model - Ruby on Rails - (2012-06-23)
  [3777] Multiple views in a single appication - sharing common parts of the template - Ruby on Rails - (2012-06-23)
  [3772] Hello World - Ruby on Rails - a checklist of each step - (2012-06-22)
  [3756] Ruby on Rails - how it flows, and where the files go - (2012-06-08)
  [2609] Scope of variables - important to Ruby on Rails - (2010-01-31)
  [2607] Answers on Ruby on Rails - (2010-01-30)
  [2605] Ruby on Rails - a sample application to teach you how - (2010-01-30)
  [1745] Moodle, Drupal, Django (and Rails) - (2008-08-08)
  [1375] Python v Ruby - (2007-10-02)
  [1302] Ruby, Ruby, Ruby. Rails, Rails, Rails. - (2007-08-13)
  [1050] The HTML++ Metalanguage - (2007-01-22)

Y306 - Python - The Django web framework
  [4095] Django - first steps - Updated - (2013-05-19)
  [3698] How to stop forms on other sites submitting to your scripts - (2012-04-15)
  [3640] Sessions (Shopping Carts) in Django - the Python Web Framework - (2012-03-05)
  [3639] Demonstration of a form using Django - (2012-03-04)
  [3634] Defining database relations in your Django model - (2012-03-02)
  [3633] Nesting Templates in Django - (2012-03-02)
  [3140] Django - separating the HTML from the view / model - (2011-01-20)
  [3139] Steering our Python courses towards wxPython, SQLite and Django - (2011-01-19)
  [3138] Django - adding your own views, and then templating your views. - (2011-01-18)
  [3136] A framework with python - Django - first steps - (2011-01-17)

Back to
Some TestWise examples - helping use Ruby code to check your web site operation
Previous and next
Horse's mouth home
Forward to
An update on Billy the Greyhound and Gypsy the Lurcher
Some other Articles
Historic Drawings from near Melksham
Meeting Report - Tuesday 21st Feb - to Melksham Chamber of Commerce from Shadow Community Operations Board
There is so much to see travelling by train
An update on Billy the Greyhound and Gypsy the Lurcher
Why do we need a Model, View, Controller architecture?
Some TestWise examples - helping use Ruby code to check your web site operation
Loading Ruby classes - where does Ruby look?
Matching regular expressions, and substitutions, in Ruby
Finding the total, average, minimum and maximum in a program
Ruby v Perl - a comparison example
4728 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3624_Why ... ture-.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat