Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
An example of Model-View-Controller techniques in a Perl / CGI script

Separating out the look and feel of a web application, the calculation logic involved therein, the standard stuff that's needed in most web applications, and the glue that holds the pieces together was become pretty standard web programming practise.

We call the look and feel the VIEW
We call the calculation logic the MODEL
We call the standard stuff that runs it all the FRAMEWORK
We call the glue holding it together the CONTROLLER
And we call the standard functions we need to do extra bits the HELPERS

If you have with a very small application, then all this separating out of elements is more trouble than it's worth ... and on our courses, we start with small applications. However, in the last couple of days I wrote a Perl script using the Common Gateway Interface as part of a web server deployment course, and split it down to show where the elements come from. The complete script is here and you can run it [here].

Take a look at the script, projected here on the left, and you'll see the work I did on the course to show delegates where each of the elements lie in my simple script.

• the HTML at the page base is the view
• the calculation code to convert a height and weight into a BMI is the model
• the logic that takes and checks the inputs, calls the model and puts the results into a hash is the controller
• Helpers populate the view with the contents of the hash and output them
• the framework is new code that's written to wrap the other components together.

So the actual code ...
The Framework - [here]
The Model - [here]
The View - [here]
The Controller - [here]
and the Helpers [here].

(written 2014-11-20)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P774 - Perl - Good CGI scripting.
  [4391] Refactoring Perl applications to give them a rosy future - (2015-01-11)
  [263] Harmony - (2005-03-31)
  [262] A little bit of fun - the new Perl Quiz - (2005-03-30)
  [261] Putting a form online - (2005-03-29)

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)
  [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)
  [3624] Why do we need a Model, View, Controller architecture? - (2012-02-25)
  [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)


Back to
PHP - some quick fixes if scripts have issues, and how to use our support
Previous and next
or
Horse's mouth home
Forward to
Are administration / review charges on hotel guests acceptable?
Some other Articles
Learning to program - variables and constants
Learning to program - Loop statements such as while
Learning to Program - the conditional statement (if)
Are administration / review charges on hotel guests acceptable?
An example of Model-View-Controller techniques in a Perl / CGI script
PHP - some quick fixes if scripts have issues, and how to use our support
Learning to Program - how we start to teach you at Well House Consultants
Java - an update of the basics
Too many Staffies, too many lurchers
Welcoming genuine forum posters quickly - but turning away off topic advertisers
4759 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, 96 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., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4320_An- ... cript.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat