MVC - A day excursion...

Sorry I've been gone for quite some time, but I've been out fishing in the very different waters of PHP and MySQL. So one of the things I had fun doing was working with MVC design patterns and thought it would be fun to make a very simple, extensible and easy to understand MVC for Perl. You can go out and find many writings and frameworks on this subject but my intent here is to make this more of a day excursion as opposed to a life long journey. I also would like to start working from the ground up, using just core Perl and its standard modules if possible. Hopefully after all this I will end up with an easy to use Perl based framework that is easy to understand and extend as I need.

So for this fishing excursion lets take a look at what I will putting in my tackle box. An MVC or Model View Controller, is a design pattern that separates and modularize the basic aspects of a dynamic web session or request.

The Controller is the entry point to the web application and routes the user requests to the appropriate action to be performed. This will take the context of "[controller]/[action]" to keep the routing simple. Routing is the process the controller uses to select the requested controller/action to be used. The Action is where the waves meet the bow, the action uses the request parameters to interact with the  data from the the model then passes the information required to the view. The Model is the data persistence layer of the application and encapsulates methods to store or retrieve data from the services that are needed like databases, data caches and system files. In the action the data can also be used to drive the application logic to provide calculated and/or transformed information needed for the user response. The View encapsulates the user response by taking the data from the action then formatting and displaying it to the users. For the formatting layer I will be using a templating  system to keep any display logic out of the controllers or actions. Finally for my own preference I will be using OOP techniques to keep each of these components separated and distinct.

For the next part of my adventure I'm going take a look below decks. I will examine what is a basic web request and how Perl perceives the various type of requests so I can use this as building block to move beyond the basics.  Part 2 Looking in the Bilge...

    1 comment:

    1. Fantastic website! Among my aspirations was to become a few months before it became a fact and Scuba Tutor. I visited with one-of my close friends at Indonesia and he show this guys Leap that are supplying diverse form of PADI instruction to me. Strongly suggested! If someone is interested may find more information here –