Book Image

Catalyst 5.8: the Perl MVC Framework

By : Antano Solar John
Book Image

Catalyst 5.8: the Perl MVC Framework

By: Antano Solar John

Overview of this book

<p>Many web applications are implemented in a way that makes developing them difficult and repetitive. Catalyst is an open source Perl-based Model-View-Controller framework that aims to solve this problem by reorganizing your web application to design and implement it in a natural, maintainable, and testable manner, making web development fun, fast, and rewarding.<br /><br />This book teaches you how to use Catalyst to weave the various components involved in a web application, using methods and tools you personally prefer along with recommendations and details on the most popularly used objects like the DBIX ORM, TT2 Template, and Moose.<br /><br />This book will take you from how the MVC pattern simplifies creating quality applications to how Catalyst allows you to tap this power instantly. It explains advanced design patterns and concludes with the improvements that Moose brings to all this. It also incorporates valuable suggestions and feedback received from the community members and our customers. By the end of the book, you will be able to build clean, scalable, and extendable web applications. This book embodies Catalyst's philosophies of Do It Yourself and Don't Repeat Yourself.</p>
Table of Contents (16 chapters)
Catalyst 5.8
Credits
About the Author
About the Reviewer
Preface
7
Hot Web Topics
Index

Chapter 1. Introduction to Catalyst

Writing a web application is usually a repetitive process. For every page, you create a new script. This script performs essentially the same tasks as the other scripts in the application such as connecting to a database, getting some input from the user, and producing a web page as the result. This style of application design results in a structure, as shown in the following screenshot:

It may be useful to note that this concerns traditional non-framework designs, as there are more web frameworks for Perl.

Building an application with this sort of design is certainly not a difficult process, but the constant repetition can be prone to error. If you decide to change your database, you will have to update the database connection string in each file. If you happen to forget one obscure file, you might not be aware until your users start sending you angry e-mails.

Of course, this problem is not limited to the database connection strings. As the next diagram shows, repeated elements are there everywhere. As each page generates its own HTML, a request from your web designer to update the layout of a page will involve having to dig through your Perl source code (potentially breaking database queries or other logic), just to change some HTML. In addition, whenever you make a change that affects your entire site or application, you'll have to make the change a number of times—once for each page. Similarly, fixing one bug will entail copying the fix to every other place. This is inconvenient, a waste of time, and just plain boring.

Catalyst is an open source Perl-based Model-View-Controller (MVC) framework that aims to solve this problem by reorganizing your web application.