Maypole::Manual::About 2.11 review

by on

This chapter serves as a gentle introduction to Maypole and setting up Maypole applications

License: Perl Artistic License
File size: 143K
Developer: Maypole::Manual::About Team
0 stars award from

This chapter serves as a gentle introduction to Maypole and setting up Maypole applications. We look at what Maypole is, how to get it up and running, and how to start thinking about building Maypole applications.

What is Maypole?

Presumably you have some idea of what Maypole is all about, or otherwise you wouldn't be reading this manual. But Maypole is good at many different things, and you may have accidentally focussed on one aspect of Maypole while missing the big picture.

For instance, you may know that Maypole is extremely good at putting web front-ends onto databases. This is true, but it's only a part of what Maypole does. You may have heard that Maypole is a web application framework, which is true, but it doesn't mean very much. There are a huge number of things that Maypole can do, because it's very much a blank slate. You can make it do what you will. In this manual, we'll be making it act as a front-end to a database, as a social network site, as an intranet portal, and many other things besides.It is a framework.

I like to think that Maypole is a way of going from a URL to a method call to some output. If you have a URL like /product/order/12, Maypole is a way of having it load up product number 12, call an order method, and produce a page about what it's just done. The reason Maypole is such a big deal is because it does all this for you. You no longer have to care about your web server. You hardly have to care about your database. You don't have to care about templating modules, parsing CGI parameters, or anything else. You only need to care about business logic, and the business logic in this instance is how you order a product, and what you need to display about it once you've done so. This is what programming should be: only caring about the work that distinguishes one program from another.

It does this using a technique called MVC for web applications.

What is MVC for web applications?

Maypole was originally called Apache::MVC, reflecting its basis in the Model-View-Controller design pattern. (I had to change it firstly because Maypole isn't tied to Apache, and secondly because Apache::MVC is a really dull name.) It's the same design pattern that forms the foundation of similar projects in other languages, such as Java's Struts framework.

This design pattern is found primarily in graphical applications; the idea is that you have a Model class which represents and manipulates your data, a View class which is responsible for displaying that data to the user, and a Controller class which controls the other classes in response to events triggered by the user. This analogy doesn't correspond precisely to a web-based application, but we can take an important principle from it. As Template Toolkit author Andy Wardley explains:

What the MVC-for-the-web crowd are really trying to achieve is a clear
separation of concerns. Put your database code in one place, your
application code in another, your presentation code in a third place.
That way, you can chop and change different elements at will,
hopefully without affecting the other parts (depending on how well your
concerns are separated, of course). This is common sense and good practice.
MVC achieves this separation of concerns as a by-product of clearly
separating inputs (controls) and outputs (views).

This is what Maypole does. It has a number of database drivers, a number of front-end drivers and a number of templating presentation drivers. In common cases, Maypole provides precisely what you need for all of these areas, and you get to concentrate on writing just the business logic of your application. This is one of the reasons why Maypole lets you develop so rapidly: because most of the time, you don't need to do any development at all.


Maypole::Manual::About 2.11 search tags